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 89 90 91
| #include "Include.h"
double a=0;
void SetupPixelFormat(HDC hDC)
{
PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR), //taille du descripteur de format
1, //version
PFD_SUPPORT_OPENGL |
PFD_DRAW_TO_WINDOW |
PFD_DOUBLEBUFFER, //Propriété
PFD_TYPE_RGBA, //Mode de couleurs
16, //Bits de couleur
0, 0, 0, 0, 0, 0, //Paramètres des couleurs
0,0, //Paramètres alpha
0,0, 0, 0, 0, //Paramètres du buffer d'accumulation
32, //Bits de profondeur
0, //Bits du buffer stencil
0, //Nombre de buffers auxiliaires
0, //ignoré (obsolète)
0, //réservé/code>
0, //ignoré (obsolète)
0, //Couleur de transparence
0 //Ignoré (obsolète)
};
int pixelFormat;
pixelFormat = ChoosePixelFormat(hDC, &pfd);
if (!pixelFormat)
{
MessageBox
(
WindowFromDC(hDC),
"Mode graphique non supporté",
"Problème",
MB_ICONERROR | MB_OK
);
exit(1);
/*Vérifie si un PixelFormat du type demandé existe*/
}
if (!SetPixelFormat(hDC, pixelFormat, &pfd))
{
MessageBox
(
WindowFromDC(hDC),
"Mode graphique non supporté",
"Problème",
MB_ICONERROR | MB_OK
);
exit(1);
/*Applique le PixelFormat. Arrête si erreur*/
}
}
void Draw()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
gluLookAt(3,2,3,0,0,0,0,1,0);
glBegin(GL_LINES);
glVertex2i(0,0);glVertex2i(0,1);
glVertex2i(0,0);glVertex2i(1,0);
glVertex2i(0,0);glVertex3i(0,0,1);
glEnd();
glLoadIdentity();
SwapBuffers(hDC); // glutSwapBuffers(); pour glut
}
void Reshape(int width, int height)
{
float r;
r=width/height;
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.,r,0.1,100.);
}
void InitGL()
{
} |
Partager