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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glut32.lib")
#pragma comment(linker, "/subsystem:\"windows\" \
/entry:\"mainCRTStartup\"")
#include <gl/glut.h>
void affichage(void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,2.0,0,0,0,0,1,0);
glBegin(GL_TRIANGLES);
glColor3f(1,1,0);//jaune
glVertex3f(0,0,0);
glVertex3f(1,1,0);
glVertex3f(0,1,0);
glColor3f(0,0,0);//noir
glVertex3f(0,0,1);
glVertex3f(1,1,1);
glVertex3f(0,1,1);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.2,0.3,0.8);//bleu
glVertex3f(1,1,1);
glVertex3f(0,1,1);
glVertex3f(0,1,0);
glVertex3f(1,1,0);
glColor3f(0.8,0,0);//rouge
glVertex3f(1,1,1);
glVertex3f(0,0,1);
glVertex3f(0,0,0);
glVertex3f(1,1,0);
glColor3f(0,0.8,0);//vert
glVertex3f(0,1,1);
glVertex3f(0,0,1);
glVertex3f(0,0,0);
glVertex3f(0,1,0);
glEnd();
glutSwapBuffers();
}
void clavier(unsigned char touche,int x,int y){
if(touche == 27) /*la touche 'Echap' pour quitter le programme */
exit(0);
}
int main(int argc, char *argv[]){
//init de glut
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowPosition(0,0);
glutInitWindowSize(800,800);
glutCreateWindow("title");
glutFullScreen();
glClearColor(0.0f,1.0f,1.0f,0.0f);
//no transparence
glEnable(GL_DEPTH_TEST);
//fonctions de rappel
glutDisplayFunc(affichage);
glutKeyboardFunc(clavier);
//boucle principale
glutMainLoop();
return 0;
} |
Partager