Added icosahedron
This commit is contained in:
parent
9a710c4687
commit
6249576d88
BIN
PlanetMiner
BIN
PlanetMiner
Binary file not shown.
BIN
bin/main.o
BIN
bin/main.o
Binary file not shown.
BIN
bin/worldgen.o
BIN
bin/worldgen.o
Binary file not shown.
124
src/main.c
124
src/main.c
@ -2,6 +2,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@ -71,31 +73,86 @@ 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[] = {
|
||||||
|
// BAC
|
||||||
1.0f, 0.0f, 2.0f,
|
1.0f, 0.0f, 2.0f,
|
||||||
2.0f, 1.0f, 0.0f,
|
2.0f, 1.0f, 0.0f,
|
||||||
|
0.0f, 2.0f, 1.0f,
|
||||||
BAC
|
// BCH
|
||||||
BCH
|
1.0f, 0.0f, 2.0f,
|
||||||
BHF
|
0.0f, 2.0f, 1.0f,
|
||||||
BFG
|
-1.0f, 0.0f, 2.0f,
|
||||||
BGA
|
// BHF
|
||||||
|
1.0f, 0.0f, 2.0f,
|
||||||
AIC
|
-1.0f, 0.0f, 2.0f,
|
||||||
ICD
|
0.0f, -2.0f, 1.0f,
|
||||||
CDH
|
// BFG
|
||||||
DHJ
|
1.0f, 0.0f, 2.0f,
|
||||||
HJF
|
0.0f, -2.0f, 1.0f,
|
||||||
JFL
|
2.0f, -1.0f, 0.0f,
|
||||||
FLG
|
// BGA
|
||||||
LGE
|
1.0f, 0.0f, 2.0f,
|
||||||
GEA
|
2.0f, -1.0f, 0.0f,
|
||||||
EAI
|
2.0f, 1.0f, 0.0f,
|
||||||
|
// AIC
|
||||||
KEI
|
2.0f, 1.0f, 0.0f,
|
||||||
KID
|
0.0f, 2.0f, -1.0f,
|
||||||
KDJ
|
0.0f, 2.0f, 1.0f,
|
||||||
KJL
|
// ICD
|
||||||
KLE
|
0.0f, 2.0f, -1.0f,
|
||||||
|
0.0f, 2.0f, 1.0f,
|
||||||
|
-2.0f, 1.0f, 0.0f,
|
||||||
|
// CDH
|
||||||
|
0.0f, 2.0f, 1.0f,
|
||||||
|
-2.0f, 1.0f, 0.0f,
|
||||||
|
-1.0f, 0.0f, 2.0f,
|
||||||
|
// DHJ
|
||||||
|
-2.0f, 1.0f, 0.0f,
|
||||||
|
-1.0f, 0.0f, 2.0f,
|
||||||
|
-2.0f, -1.0f, 0.0f,
|
||||||
|
// HJF
|
||||||
|
-1.0f, 0.0f, 2.0f,
|
||||||
|
-2.0f, -1.0f, 0.0f,
|
||||||
|
0.0f, -2.0f, 1.0f,
|
||||||
|
// JFL
|
||||||
|
-2.0f, -1.0f, 0.0f,
|
||||||
|
0.0f, -2.0f, 1.0f,
|
||||||
|
0.0f, -2.0f, -1.0f,
|
||||||
|
// FLG
|
||||||
|
0.0f, -2.0f, 1.0f,
|
||||||
|
0.0f, -2.0f, -1.0f,
|
||||||
|
2.0f, -1.0f, 0.0f,
|
||||||
|
// LGE
|
||||||
|
0.0f, -2.0f, -1.0f,
|
||||||
|
2.0f, -1.0f, 0.0f,
|
||||||
|
1.0f, 0.0f, -2.0f,
|
||||||
|
// GEA
|
||||||
|
2.0f, -1.0f, 0.0f,
|
||||||
|
1.0f, 0.0f, -2.0f,
|
||||||
|
2.0f, 1.0f, 0.0f,
|
||||||
|
// EAI
|
||||||
|
1.0f, 0.0f, -2.0f,
|
||||||
|
2.0f, 1.0f, 0.0f,
|
||||||
|
0.0f, 2.0f, -1.0f,
|
||||||
|
// KEI
|
||||||
|
-1.0f, 0.0f, -2.0f,
|
||||||
|
1.0f, 0.0f, -2.0f,
|
||||||
|
0.0f, 2.0f, -1.0f,
|
||||||
|
// KID
|
||||||
|
-1.0f, 0.0f, -2.0f,
|
||||||
|
0.0f, 2.0f, -1.0f,
|
||||||
|
-2.0f, 1.0f, 0.0f,
|
||||||
|
// KDJ
|
||||||
|
-1.0f, 0.0f, -2.0f,
|
||||||
|
-2.0f, 1.0f, 0.0f,
|
||||||
|
-2.0f, -1.0f, 0.0f,
|
||||||
|
// KJL
|
||||||
|
-1.0f, 0.0f, -2.0f,
|
||||||
|
-2.0f, -1.0f, 0.0f,
|
||||||
|
0.0f, -2.0f, -1.0f,
|
||||||
|
// KLE
|
||||||
|
-1.0f, 0.0f, -2.0f,
|
||||||
|
0.0f, -2.0f, -1.0f,
|
||||||
|
1.0f, 0.0f, -2.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
GLuint vertexbuffer;
|
GLuint vertexbuffer;
|
||||||
@ -107,37 +164,42 @@ int main()
|
|||||||
|
|
||||||
printf("Entering main loop\n");
|
printf("Entering main loop\n");
|
||||||
|
|
||||||
|
float theta = 0.0f;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
glClear( GL_COLOR_BUFFER_BIT );
|
glClear( GL_COLOR_BUFFER_BIT );
|
||||||
|
|
||||||
if( glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS )
|
if( glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS )
|
||||||
{
|
{
|
||||||
eye.z -= 0.05f;
|
//eye.z -= 0.05f;
|
||||||
}
|
}
|
||||||
if( glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS )
|
if( glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS )
|
||||||
{
|
{
|
||||||
eye.z += 0.05f;
|
// eye.z += 0.05f;
|
||||||
}
|
}
|
||||||
if( glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS )
|
if( glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS )
|
||||||
{
|
{
|
||||||
eye.x += 0.05f;
|
theta += 0.05f;
|
||||||
}
|
}
|
||||||
if( glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS )
|
if( glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS )
|
||||||
{
|
{
|
||||||
eye.x -= 0.05f;
|
theta -= 0.05f;
|
||||||
}
|
}
|
||||||
if( glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS )
|
if( glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS )
|
||||||
{
|
{
|
||||||
eye.y += 0.05f;
|
// eye.y += 0.05f;
|
||||||
}
|
}
|
||||||
if( glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS )
|
if( glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS )
|
||||||
{
|
{
|
||||||
eye.y -= 0.05f;
|
// eye.y -= 0.05f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eye.x = (float)sin((double)theta);
|
||||||
|
eye.z = (float)cos((double)theta);
|
||||||
|
|
||||||
|
|
||||||
center = glms_vec3_add(eye, direction);
|
// center = glms_vec3_add(eye, direction);
|
||||||
|
|
||||||
mat4s view = glms_lookat(eye, center, up);
|
mat4s view = glms_lookat(eye, center, up);
|
||||||
mat4s model = glms_mat4_identity();
|
mat4s model = glms_mat4_identity();
|
||||||
@ -159,7 +221,7 @@ int main()
|
|||||||
(void*)0
|
(void*)0
|
||||||
);
|
);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 12*3);
|
glDrawArrays(GL_TRIANGLES, 0, 20*3);
|
||||||
glDisableVertexAttribArray(0);
|
glDisableVertexAttribArray(0);
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
Loading…
Reference in New Issue
Block a user