From 51b8e2109fb8c58290843689e0820ce4f9f10641 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 17 Jun 2014 23:26:46 -0400 Subject: [PATCH] map coordinates 1:1 to pixels --- sdl_tmplt.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sdl_tmplt.c b/sdl_tmplt.c index 3359c6f..27f7508 100644 --- a/sdl_tmplt.c +++ b/sdl_tmplt.c @@ -14,20 +14,27 @@ void init(void) glViewport(0, 0, WIDTH, HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(60.0, (GLfloat)WIDTH/(GLfloat)WIDTH, 1.0, 30.0); + glOrtho(-0.5, WIDTH - 0.5, -0.5, HEIGHT - 0.5, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef(0.0, 0.0, -3.6); } void display(SDL_Window * window) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glColor3f(1, 1, 1); glBegin(GL_QUADS); - glVertex3f(-2.0, -1.0, 0.0); - glVertex3f(-2.0, 1.0, 0.0); - glVertex3f(0.0, 1.0, 0.0); - glVertex3f(0.0, -1.0, 0.0); + glVertex3f(10, HEIGHT / 2, 0.0); + glVertex3f(10, 3 * HEIGHT / 4, 0.0); + glVertex3f(WIDTH / 2, 3 * HEIGHT / 4, 0.0); + glVertex3f(WIDTH / 2, HEIGHT / 2, 0.0); + glEnd(); + glColor3f(1, 0.6, 0); + glBegin(GL_LINE_LOOP); + glVertex2f(0, 0); + glVertex2f(WIDTH - 1, 0); + glVertex2f(WIDTH - 1, HEIGHT - 1); + glVertex2f(0, HEIGHT - 1); glEnd(); SDL_GL_SwapWindow(window); }