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
|
//---------------------------------------------------------------------------
#include <windows.h>
#include <glut.h>
#include <vcl.h>
#pragma hdrstop
void Affichage();
void clavier(unsigned char touche,int x,int y);
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
/* Initialisation de GLUT */
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(200,200);
glutCreateWindow("FenetreGlut");
/* Initialisation OpenGL */
glClearColor(0.0,0.0,0.0,0.0);
glColor3f(1.0,1.0,1.0);
glPointSize(2.0);
/* Enregistrement des fonctions de rappel */
glutDisplayFunc(Affichage);
glutKeyboardFunc(clavier);
/* Entré dans la boucle principal GLUT */
glutMainLoop();
return 0;
}
//---------------------------------------------------------------------------
void Affichage()
{
/* effacement de l'image avec la couleur de fond */
glClear(GL_COLOR_BUFFER_BIT);
/* Dessin du polygone */
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.5,-0.5);
glColor3f(0.0,1.0,0.0);
glVertex2f(0.5,-0.5);
glColor3f(0.0,0.0,1.0);
glVertex2f(0.5,0.5);
glColor3f(1.0,1.0,1.0);
glVertex2f(-0.5,0.5);
glEnd();
/* on force l'affichage du résultat */
glFlush();
}
//---------------------------------------------------------------------------
void clavier(unsigned char touche,int x,int y)
{
switch(touche)
{
case'p': /*Affichage du carré plein*/
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glutPostRedisplay();
break;
case'f': /*Affichage en mode fil de fer*/
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glutPostRedisplay();
break;
case's': /*Affichage enmode sommet seul*/
glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
glutPostRedisplay();
break;
case'q': /*quitter le programme*/
exit(0);
}
} |
Partager