From 15efbe3f4d16b44bf64ca7fd3f0d318b9b1f8020 Mon Sep 17 00:00:00 2001 From: Yoann Date: Tue, 27 Sep 2011 13:14:18 +0200 Subject: [PATCH] =?UTF-8?q?Remise=20en=20forme=20des=20fonction=20d'affich?= =?UTF-8?q?age=20(S=C3=A9partion=20de=20la=20partie=20de=20rendu=20de=20la?= =?UTF-8?q?=20partie=20d'initialisation).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- display.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/display.c b/display.c index bfd7539..914890e 100644 --- a/display.c +++ b/display.c @@ -2,6 +2,8 @@ #include #include +void renderScene(); + int main(int argc, char *argv[]) { short continuer; SDL_Event event; @@ -13,6 +15,7 @@ int main(int argc, char *argv[]) { SDL_SetVideoMode(640, 480, 32, SDL_OPENGL); continuer = 1; + while (continuer) { SDL_WaitEvent(&event); @@ -21,25 +24,28 @@ int main(int argc, char *argv[]) { continuer = 0; } - glClear(GL_COLOR_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - - glBegin(GL_TRIANGLES); - glColor3ub(255,0,0); glVertex3d(-0.75,-0.75,0); - glColor3ub(0,255,0); glVertex3d(0,0.75,0); - glColor3ub(0,0,255); glVertex3d(0.75,-0.75,0); - glEnd(); - - glFlush(); - SDL_GL_SwapBuffers(); + renderScene(); } SDL_Quit(); return 0; } + +void renderScene() { + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3ub(255,0,0); glVertex3d(-0.75,-0.75,0); + glColor3ub(0,255,0); glVertex3d(0,0.75,0); + glColor3ub(0,0,255); glVertex3d(0.75,-0.75,0); + glEnd(); + + glFlush(); + SDL_GL_SwapBuffers(); +}