I have the code below, which sets my pixel format. But, the problem is that this code runs properly in my computer although it cannot set pixel format in some of other computers. Does SetPixelFormat function have any relationship with hardware or type of monitor or desktop settings etc…? Is there anything wrong which I cannot see?
/////////////////////////////////////////////////////////////////////////
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 24-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
32, // 32-bit z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
int iPixelFormat;
if((iPixelFormat = ChoosePixelFormat(hdc, &pfd)) == 0)
{
MessageBox(NULL, “ChoosePixelFormat Failed”, NULL, MB_OK);
return 0;
}
if(SetPixelFormat(hdc, iPixelFormat, &pfd) == FALSE)
{
MessageBox(NULL, “SetPixelFormat Failed”, NULL, MB_OK);
return 0;
}
/////////////////////////////////////////////////////////////////