1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("Mon premier programme OpenGL !",NULL);
SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDisable(GL_COLOR_MATERIAL);
bool continuer = true;
SDL_Event event;
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = false;
}
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
GLfloat mat_diffuse1[] = { 1.0, 0.0, 0.0, 1.0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse1);
glVertex3f(0, 0, 0);
GLfloat mat_diffuse2[] = { 0.0, 1.0, 0.0, 1.0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse2);
glVertex3f(1, 0, 0);
GLfloat mat_diffuse3[] = { 0.0, 0.0, 1.0, 1.0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse3);
glVertex3f(1, 1, 0);
glEnd();
glFlush();
SDL_GL_SwapBuffers();
}
SDL_Quit();
return 0;
} |
Partager