1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| PIXELFORMATDESCRIPTOR PixelFormatDesc;
memset(&PixelFormatDesc, 0, sizeof (PIXELFORMATDESCRIPTOR));
PixelFormatDesc.nSize = sizeof(PIXELFORMATDESCRIPTOR);
PixelFormatDesc.nVersion = 1;
PixelFormatDesc.dwFlags = PFD_DRAW_TO_BITMAP |PFD_SUPPORT_OPENGL |PFD_SUPPORT_GDI | PFD_DOUBLEBUFFER_DONTCARE | PFD_STEREO_DONTCARE| PFD_GENERIC_ACCELERATED;
if ((GetDeviceCaps(hDc, RASTERCAPS) & RC_PALETTE)==RC_PALETTE)
{
PixelFormatDesc.iPixelType = PFD_TYPE_COLORINDEX;
}
else{
PixelFormatDesc.iPixelType = PFD_TYPE_RGBA;
}
PixelFormatDesc.cColorBits = GetDeviceCaps(hDc, BITSPIXEL);
PixelFormatDesc.cDepthBits = 32;
PixelFormatDesc.iLayerType = PFD_MAIN_PLANE;
// On choisit le format de pixels
int nPixelFormat = ChoosePixelFormat(hDc, &PixelFormatDesc);
if (0 == nPixelFormat)
{
// Pas de format de pixel disponible
return false;
}
// On définit le format de pixel
if (!SetPixelFormat(hDc, nPixelFormat, &PixelFormatDesc))
{
return false;
} |
Partager