fix perspective projection

This commit is contained in:
Josh Holtrop 2015-10-13 21:57:21 -04:00
parent 17edc0a9d6
commit eb83cb256e

4
app.cc
View File

@ -67,7 +67,7 @@ bool init(void)
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *)(3 * sizeof(GLfloat))); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *)(3 * sizeof(GLfloat)));
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *)(6 * sizeof(GLfloat))); glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *)(6 * sizeof(GLfloat)));
projection = glm::perspective(60.0f, (float)WIDTH / (float)HEIGHT, 0.1f, 1000.0f); projection = glm::perspective((float)(60.0 * M_PI / 180.0), (float)WIDTH / (float)HEIGHT, 0.1f, 1000.0f);
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
@ -124,7 +124,7 @@ static void draw_cube()
void display(SDL_Window * window) void display(SDL_Window * window)
{ {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelview = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, -2)); modelview = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, -5));
modelview = glm::rotate(modelview, (float)(SDL_GetTicks() / 1000.0), glm::vec3(0, 1, 0)); modelview = glm::rotate(modelview, (float)(SDL_GetTicks() / 1000.0), glm::vec3(0, 1, 0));
draw_cube(); draw_cube();