Hi, I'm working on some OpenGL in C++ in Visual Studio 2005.
// SetUpOpenGL sets the pixel format and a rendering
// context then returns the RC
HGLRC COpenGLBaseWnd::SetUpOpenGL(HWND hwnd)
{
static PIXELFORMATDESCRIPTOR pfd =
{
sizeof (PIXELFORMATDESCRIPTOR), // strcut size
1, // Version number
PFD_DRAW_TO_WINDOW | // Flags, draw to a window,
PFD_DOUBLEBUFFER | // enable double buffering
PFD_SUPPORT_OPENGL, // use OpenGL
PFD_TYPE_RGBA, // RGBA pixel values
24, // 24-bit color
0, 0, 0, // RGB bits & shift sizes.
0, 0, 0, // Don't care about them
0, 0, // No alpha buffer info
0, 0, 0, 0, 0, // No accumulation buffer
32, // 32-bit depth buffer
0, // No stencil buffer
0, // No auxiliary buffers
PFD_MAIN_PLANE, // Layer type
0, // Reserved (must be 0)
0, // No layer mask
0, // No visible mask
0 // No damage mask
};
pCDC = pWnd->GetDC();
hDC = pCDC->GetSafeHdc();
PixelFormatID = ChoosePixelFormat(hDC, &pfd);
if (!PixelFormatID)
{
// catch errors here.
// If nMyPixelFormat is zero, then there's
// something wrong... most likely the window's
// style bits are incorrect (in CreateWindow() )
// or OpenGl isn't installed on this machine
//printf("ChoosePixelFormat Failed %d\r\n",GetLastError());
abort();
exit(-1);
}
if (pfd.dwFlags & PFD_NEED_PALETTE)
{
//printf("Choosen Pixel Format requires a palette.\r\n");
abort();
exit(-1);
}
SetPixelFormat(hDC, PixelFormatID, &pfd);
And that SetPixelFormat call's where it goes bang during run-time. The annoying thing is, it only crashes on my machine, not on my colleague's.
I found this answer, which looks related, on stackoverflow, but either I don't know what to do to fix the problem using this information in C++, or it's not the same problem.
I need advice on how to implement that solution in C++, or other potential solutions.