From 57f984c92a9787517e18d7b26c79102c53e2ca59 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 30 Apr 2011 11:42:23 -0400 Subject: [PATCH] switch to perspective projection --- template/test.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/template/test.cc b/template/test.cc index 08d934f..73db8bb 100644 --- a/template/test.cc +++ b/template/test.cc @@ -21,7 +21,7 @@ const GLfloat data[][2][3] = { {{-0.6, 0.6, 0.0}, {0, 0, 1}}, {{0.2, -0.6, 0.0}, {1, 0, 0}}, {{1.0, -0.6, 0.0}, {0, 1, 0}}, - {{0.6, 0.6, -500.0}, {0, 0, 1}} + {{0.6, 0.6, -10.0}, {0, 0, 1}} }; const GLushort indices[] = { 0, 1, 2, 3, 4, 5 @@ -132,10 +132,13 @@ bool init(int width, int height) glViewport(0, 0, WIDTH, HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho((float)-width/(float)height, (float)width/(float)height, - -1, 1, 1000, -1000); + float near = 0.1; + float scale = near * 0.577 * 2; + float aspect = (float)width / (float)height; + glFrustum(-aspect * scale, aspect * scale, -scale, scale, near, 1000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + glTranslatef(0, 0, -1); vs = makeShader(GL_VERTEX_SHADER, "v_shader.glsl"); fs = makeShader(GL_FRAGMENT_SHADER, "f_shader.glsl");