Started adding vertices for icosohedron
This commit is contained in:
parent
ef44b24798
commit
9a710c4687
BIN
PlanetMiner
BIN
PlanetMiner
Binary file not shown.
BIN
bin/main.o
BIN
bin/main.o
Binary file not shown.
BIN
bin/worldgen.o
Normal file
BIN
bin/worldgen.o
Normal file
Binary file not shown.
68
src/main.c
68
src/main.c
@ -71,42 +71,31 @@ int main()
|
|||||||
vec3s up = {0.0f, 1.0f, 0.0f};
|
vec3s up = {0.0f, 1.0f, 0.0f};
|
||||||
|
|
||||||
static const GLfloat g_vertex_buffer_data[] = {
|
static const GLfloat g_vertex_buffer_data[] = {
|
||||||
-1.0f,-1.0f,-1.0f, // triangle 1 : begin
|
1.0f, 0.0f, 2.0f,
|
||||||
-1.0f,-1.0f, 1.0f,
|
2.0f, 1.0f, 0.0f,
|
||||||
-1.0f, 1.0f, 1.0f, // triangle 1 : end
|
|
||||||
1.0f, 1.0f,-1.0f, // triangle 2 : begin
|
BAC
|
||||||
-1.0f,-1.0f,-1.0f,
|
BCH
|
||||||
-1.0f, 1.0f,-1.0f, // triangle 2 : end
|
BHF
|
||||||
1.0f,-1.0f, 1.0f,
|
BFG
|
||||||
-1.0f,-1.0f,-1.0f,
|
BGA
|
||||||
1.0f,-1.0f,-1.0f,
|
|
||||||
1.0f, 1.0f,-1.0f,
|
AIC
|
||||||
1.0f,-1.0f,-1.0f,
|
ICD
|
||||||
-1.0f,-1.0f,-1.0f,
|
CDH
|
||||||
-1.0f,-1.0f,-1.0f,
|
DHJ
|
||||||
-1.0f, 1.0f, 1.0f,
|
HJF
|
||||||
-1.0f, 1.0f,-1.0f,
|
JFL
|
||||||
1.0f,-1.0f, 1.0f,
|
FLG
|
||||||
-1.0f,-1.0f, 1.0f,
|
LGE
|
||||||
-1.0f,-1.0f,-1.0f,
|
GEA
|
||||||
-1.0f, 1.0f, 1.0f,
|
EAI
|
||||||
-1.0f,-1.0f, 1.0f,
|
|
||||||
1.0f,-1.0f, 1.0f,
|
KEI
|
||||||
1.0f, 1.0f, 1.0f,
|
KID
|
||||||
1.0f,-1.0f,-1.0f,
|
KDJ
|
||||||
1.0f, 1.0f,-1.0f,
|
KJL
|
||||||
1.0f,-1.0f,-1.0f,
|
KLE
|
||||||
1.0f, 1.0f, 1.0f,
|
|
||||||
1.0f,-1.0f, 1.0f,
|
|
||||||
1.0f, 1.0f, 1.0f,
|
|
||||||
1.0f, 1.0f,-1.0f,
|
|
||||||
-1.0f, 1.0f,-1.0f,
|
|
||||||
1.0f, 1.0f, 1.0f,
|
|
||||||
-1.0f, 1.0f,-1.0f,
|
|
||||||
-1.0f, 1.0f, 1.0f,
|
|
||||||
1.0f, 1.0f, 1.0f,
|
|
||||||
-1.0f, 1.0f, 1.0f,
|
|
||||||
1.0f,-1.0f, 1.0f
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GLuint vertexbuffer;
|
GLuint vertexbuffer;
|
||||||
@ -116,10 +105,11 @@ int main()
|
|||||||
|
|
||||||
vec3s direction = {0.0f, 0.0f, -5.0f};
|
vec3s direction = {0.0f, 0.0f, -5.0f};
|
||||||
|
|
||||||
|
printf("Entering main loop\n");
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
glClear( GL_COLOR_BUFFER_BIT );
|
glClear( GL_COLOR_BUFFER_BIT );
|
||||||
g
|
|
||||||
|
|
||||||
if( glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS )
|
if( glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS )
|
||||||
{
|
{
|
||||||
@ -175,7 +165,9 @@ int main()
|
|||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
while( glfwGetKey(window, GLFW_KEY_Q) | glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && !glfwWindowShouldClose(window));
|
while( (glfwGetKey(window, GLFW_KEY_Q) != GLFW_PRESS
|
||||||
|
&& glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS)
|
||||||
|
&& !glfwWindowShouldClose(window));
|
||||||
|
|
||||||
glDeleteBuffers(1, &vertexbuffer);
|
glDeleteBuffers(1, &vertexbuffer);
|
||||||
glDeleteProgram(programID);
|
glDeleteProgram(programID);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "worldgen.h"
|
#include "worldgen.h"
|
||||||
#include <cglm/struct.h>
|
#include <cglm/struct.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
|
|
||||||
#define ORDER 1
|
#define ORDER 1
|
||||||
#define RSQRT5 0.4472135954999579
|
#define RSQRT5 0.4472135954999579
|
||||||
@ -9,10 +10,12 @@ worldMesh generateWorld(vec3s position)
|
|||||||
{
|
{
|
||||||
// placeholder struct for world mesh
|
// placeholder struct for world mesh
|
||||||
worldMesh mesh;
|
worldMesh mesh;
|
||||||
vertex.count = 20 * ORDER * 3; // Icosahedron has 20 triangular sides
|
mesh.count = 20 * ORDER * 3; // Icosahedron has 20 triangular sides
|
||||||
|
|
||||||
mesh.vertices = (GLfloat*) malloc(sizeof(GLfloat) * mesh.count);
|
mesh.vertices = (GLfloat*) malloc(sizeof(GLfloat) * mesh.count);
|
||||||
populateIcosphere(mesh, ORDER, 1);
|
populateIcosphere(mesh, ORDER, 1);
|
||||||
|
|
||||||
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void populateIcosphere(worldMesh mesh, unsigned char order, float radius)
|
void populateIcosphere(worldMesh mesh, unsigned char order, float radius)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <cglm/struct.h>
|
#include <cglm/struct.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
|
|
||||||
typedef struct worldMesh {
|
typedef struct worldMesh {
|
||||||
long int count;
|
long int count;
|
||||||
|
Loading…
Reference in New Issue
Block a user