I’m having trouble getting a matrox G400 to initalise properly to do openGL rendering. The same code works fine on Voodoo 1 (!) (when set to 16 bit), TNT, and GeForce cards, but the matrox card falls over on SetPixelFormat() using the latest drivers (on NT4SP6a). Here’s a snippet of init code:
// Initialise directdraw:
if (DirectDrawCreate(NULL, &lpdd, NULL) != DD_OK)
{
printf("Failed to create directdraw
");
return -1;
}
// Step 1: set cooperative level so that we get exclusive access to the whole
// screen.
if (lpdd->SetCooperativeLevel(hWnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT) != DD_OK)
{
printf("Failed to set cooperative level
");
Destroy();
return -1;
}
// Step 2: set the display mode to 640x480x32
if (lpdd->SetDisplayMode(
640,
480,
32
) != DD_OK)
{
printf("Failed to set screen mode
");
Destroy();
return -1;
}
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DEPTH_DONTCARE |
PFD_GENERIC_ACCELERATED |
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 16-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
0, // NO z-buffer
1, // 1-bit stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
int iPixelFormat;
hdc = GetWindowDC(hWnd);
// get the best available match of pixel format for the device context
iPixelFormat = ChoosePixelFormat(hdc, &pfd);
if (iPixelFormat == 0) {
printf("Failed to choose pixel format.
");
Destroy();
return -1;
}
printf("Pixel format is %d
", iPixelFormat);
// make that the pixel format of the device context
if (SetPixelFormat(hdc, iPixelFormat, &pfd) == FALSE) {
printf("Failed to set pixel format
");
Destroy();
return -1;
}
printf("Created display
");
// Hide the mouse
ShowCursor(FALSE);
return 1;