52 lines
901 B
C
52 lines
901 B
C
#include <SDL/SDL.h>
|
|
#include <GL/glew.h>
|
|
#include <GL/glu.h>
|
|
|
|
void renderScene();
|
|
|
|
int main(int argc, char *argv[]) {
|
|
short continuer;
|
|
SDL_Event event;
|
|
|
|
argc = argc; /* Unused */
|
|
argv = argv; /* Unused */
|
|
SDL_Init(SDL_INIT_VIDEO);
|
|
SDL_WM_SetCaption("Mon premier programme OpenGL !",NULL);
|
|
SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
|
|
|
|
continuer = 1;
|
|
|
|
while (continuer) {
|
|
SDL_WaitEvent(&event);
|
|
|
|
switch(event.type) {
|
|
case SDL_QUIT:
|
|
continuer = 0;
|
|
}
|
|
|
|
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();
|
|
}
|