I’m sure everybody else already has this working, but this is the first time I’ve tried to use OpenGL with VS 2005. I initialized everything in the form load event.
HDC hDC;
HGLRC hRC;
HWND hWnd;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
hWnd = (HWND)panel3->Handle.ToInt64();
hDC = GetDC(hWnd);
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0,0,0,0,0,0,
8,0,
0,0,0,0,0,
24,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,
};
int PixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, PixelFormat, &pfd);
wglDeleteContext(hRC);
hRC = wglCreateContext(hDC);
if(hRC == NULL)
return;
if(wglMakeCurrent(hDC, hRC) == false)
return;
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_NORMALIZE);
glViewport(0, 0, panel3->Width, panel3->Height);
glClearColor(1, 0, 0, 0);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
SwapBuffers(hDC);
}
I then created a timer and inserted the same last 4 lines of the load event, simply clear the screen. But nothing is showing up? I then found out the call to wglCreateContext is failing.