cs_charliejo
Messages postés8Date d'inscriptionmardi 11 janvier 2005StatutMembreDernière intervention17 juillet 2009
-
23 févr. 2005 à 17:41
KeniiyK
Messages postés326Date d'inscriptionvendredi 13 août 2004StatutMembreDernière intervention 2 novembre 2007
-
3 mars 2005 à 22:50
Bonjour,
J'ai le code suivant pour créer plusieurs context.
int pf, maxpf;
PIXELFORMATDESCRIPTOR pfd;
LAYERPLANEDESCRIPTOR lpd; /* layer plane descriptor */
int nEntries = 2; /* number of entries in palette */
COLORREF crEntries[2] = { /* entries in custom palette */
0x00000000, /* black (ref #0 = transparent) */
0x00ff0000, /* blue */
};
/* get the maximum number of pixel formats */
maxpf = DescribePixelFormat(hDC, 0, 0, NULL);
/* find an overlay layer descriptor */
for(pf = 0; pf < maxpf; pf++) {
DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
/* the bReserved field of the PIXELFORMATDESCRIPTOR contains the
number of overlay/underlay planes */
if (pfd.bReserved > 0) {
/* aha! This format has overlays/underlays */
wglDescribeLayerPlane(hDC, pf, 1,
sizeof(LAYERPLANEDESCRIPTOR), &lpd);
if (lpd.dwFlags & LPD_SUPPORT_OPENGL && lpd.dwFlags & flags)
{
goto found;
}
}
}
found:
/* now get the "normal" pixel format descriptor for the layer */
DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
/* set the pixel format */
if(SetPixelFormat(hDC, pf, &pfd) == FALSE) {
MessageBox(NULL,
"SetPixelFormat() failed: Cannot set format specified.",
"Error", MB_OK);
return 0;
}
/* set up the layer palette */
wglSetLayerPaletteEntries(hDC, 1, 0, nEntries, crEntries);
/* realize the palette */
wglRealizeLayerPalette(hDC, 1, TRUE);
/* announce what we've got */
printf("Number of overlays = %d\n", pfd.bReserved);
printf("Color bits in the overlay = %d\n", lpd.cColorBits);
return pf;
Le problème c'est que dans la condition" if (lpd.dwFlags & LPD_SUPPORT_OPENGL && lpd.dwFlags & flags) " il ne trouve jamais un cas où on a LPD_SUPPORT_OPENGL...
Je vois pas comment faire pour obtenir cette condition ?
Je vous remercie !
A voir également:
L'adresse demandée n'est pas valide dans son contexte
cs_patatalo
Messages postés1466Date d'inscriptionvendredi 2 janvier 2004StatutModérateurDernière intervention14 février 20142 23 févr. 2005 à 19:01
salut,
est tu sur que hDC soit valide, il y a plusieurs fonctions pour l'obtenir, il faut peut etre utiliser CreateCompatibleDC ou je sais quoi encore, je suis pas spécialiste.
verifie bien tout tes retours de fonctions, tu galerera moins pour savoir d'ou vient le pb