Voila mon source qui fonctionne pas. c'est la source du chipitre 3 ( g pas ete plus loin ) de http://glinfrench.apinc.org/
Je sais pas si c'est juste mais y a pas de raison. J'ai reinstalle Dev C++ 5 beta, ce soir je reessaye GLUT.
Si vous pouviez me guider pour pas que je fasse de connerie, ce serait sympa.
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
WNDCLASS wc;
MSG msg;
HWND hWnd;
HDC DC;
HGLRC RC;
void RePaint ()
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
gluLookAt (7,7,-10,0,0,0,0,1,0);
glEnable(GL_DEPTH_TEST);
glBegin (GL_QUADS);
glColor3d (0,1,1);glVertex3i (-1,-1,1);
glColor3d (1,0,0);glVertex3i (-1,1,1);
glColor3d (0,1,0);glVertex3i (1,1,1);
glColor3d (1,0,1);glVertex3i (1,-1,1);
glColor3d (0,0,1);glVertex3i (-1,-1,-1);
glColor3d (1,1,0);glVertex3i (-1,1,-1);
glColor3d (1,1,1);glVertex3i (1,1,-1);
glColor3d (.5,.5,.5);glVertex3i (1,-1,-1);
glColor3d (1,1,0);glVertex3i (-1,1,-1);
glColor3d (1,1,1);glVertex3i (1,1,-1);
glColor3d (0,1,0);glVertex3i (1,1,1);
glColor3d (1,0,0);glVertex3i (-1,1,1);
glColor3d (0,0,1);glVertex3i (-1,-1,-1);
glColor3d (.5,.5,.5);glVertex3i (1,-1,-1);
glColor3d (1,0,1);glVertex3i (1,-1,1);
glColor3d (0,1,1);glVertex3i (-1,-1,1);
glColor3d (0,0,1);glVertex3i (-1,-1,-1);
glColor3d (0,1,1);glVertex3i (-1,-1,1);
glColor3d (1,0,0);glVertex3i (-1,1,1);
glColor3d (1,1,0);glVertex3i (-1,1,-1);
glColor3d (.5,.5,.5);glVertex3i (1,-1,-1);
glColor3d (1,0,1);glVertex3i (1,-1,1);
glColor3d (0,1,0);glVertex3i (1,1,1);
glColor3d (1,1,1);glVertex3i (1,1,-1);
glEnd();
glBegin (GL_QUADS);
glColor3d (1,0,0);
glVertex3i (-6,-1,1);
glVertex3i (-6,1,1);
glVertex3i (-4,1,1);
glVertex3i (-4,-1,1);
glColor3d (0,1,0);
glVertex3i (-6,-1,-1);
glVertex3i (-6,1,-1);
glVertex3i (-4,1,-1);
glVertex3i (-4,-1,-1);
glColor3d (1,1,0);
glVertex3i (-6,1,-1);
glVertex3i (-4,1,-1);
glVertex3i (-4,1,1);
glVertex3i (-6,1,1);
glColor3d (0,0,0);
glVertex3i (-6,-1,-1);
glVertex3i (-4,-1,-1);
glVertex3i (-4,-1,1);
glVertex3i (-6,-1,1);
glColor3d (0,1,1);
glVertex3i (-6,-1,-1);
glVertex3i (-6,-1,1);
glVertex3i (-6,1,1);
glVertex3i (-6,1,-1);
glColor3d (1,0,1);
glVertex3i (-4,-1,-1);
glVertex3i (-4,-1,1);
glVertex3i (-4,1,1);
glVertex3i (-4,1,-1);
glEnd();
glDisable(GL_DEPTH_TEST);
glBegin (GL_QUADS);
glColor3d (0,1,1);glVertex3i (4,-1,1);
glColor3d (1,0,0);glVertex3i (4,1,1);
glColor3d (0,1,0);glVertex3i (6,1,1);
glColor3d (1,0,1);glVertex3i (6,-1,1);
glColor3d (0,0,1);glVertex3i (4,-1,-1);
glColor3d (1,1,0);glVertex3i (4,1,-1);
glColor3d (1,1,1);glVertex3i (6,1,-1);
glColor3d (.5,.5,.5);glVertex3i (6,-1,-1);
glColor3d (1,1,0);glVertex3i (4,1,-1);
glColor3d (1,1,1);glVertex3i (6,1,-1);
glColor3d (0,1,0);glVertex3i (6,1,1);
glColor3d (1,0,0);glVertex3i (4,1,1);
glColor3d (0,0,1);glVertex3i (4,-1,-1);
glColor3d (.5,.5,.5);glVertex3i (6,-1,-1);
glColor3d (1,0,1);glVertex3i (6,-1,1);
glColor3d (0,1,1);glVertex3i (4,-1,1);
glColor3d (0,0,1);glVertex3i (4,-1,-1);
glColor3d (0,1,1);glVertex3i (4,-1,1);
glColor3d (1,0,0);glVertex3i (4,1,1);
glColor3d (1,1,0);glVertex3i (4,1,-1);
glColor3d (.5,.5,.5);glVertex3i (6,-1,-1);
glColor3d (1,0,1);glVertex3i (6,-1,1);
glColor3d (0,1,0);glVertex3i (6,1,1);
glColor3d (1,1,1);glVertex3i (6,1,-1);
glEnd();
SwapBuffers (DC);
}
void InitPixelFormat (HDC hDC)
{
PIXELFORMATDESCRIPTOR pfd =
{
sizeof (PIXELFORMATDESCRIPTOR),
1,
PFD_SUPPORT_OPENGL | PFD_TYPE_RGBA | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER,
16,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16,
0, 0, 0, 0, 0, 0, 0
};
SetPixelFormat (hDC, ChoosePixelFormat (hDC, &pfd), &pfd);
}
LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
DC=GetDC (hwnd);
InitPixelFormat (DC);
RC = wglCreateContext (DC);
wglMakeCurrent (DC, RC);
glEnable (GL_DEPTH_TEST);
glClearColor (0,0,1,0);
break;
case WM_CLOSE:
wglMakeCurrent (NULL, NULL);
wglDeleteContext (RC);
ReleaseDC (hwnd,DC);
PostQuitMessage (0);
break;
case WM_SIZE:
glViewport (0,0,LOWORD (lParam),HIWORD (lParam));
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (45,(float)(LOWORD(lParam))/(float)(HIWORD(lParam)),1,100);
break;
case WM_PAINT:
RePaint ();
break;
default:
return DefWindowProc (hwnd,uMsg,wParam,lParam);
break;
}
return 0;
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
{
wc.style = CS_OWNDC;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "OGL";
RegisterClass(&wc);
hWnd = CreateWindow
("OGL", "Fenetre OpenGL",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
0, 0, 640, 480, NULL, NULL, hInstance, NULL
);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}