This topic is now archived and is closed to further replies.

The C modest god

Strange DirectDraw problem

Recommended Posts

I use the following code IERRSTRING ("DirectDraw", IDirectDraw7_SetDisplayMode (pSDO->pDevice, pDDSD->dwWidth, pDDSD->dwHeight, pDDSD->ddpfPixelFormat.dwRGBBitCount, 0, 0)); INITIALDXSTRUCT (pSDO->Caps); IERRSTRING ("DirectDraw", IDirectDraw7_GetCaps (pSDO->pDevice, &(pSDO->Caps), NULL)); INITIALDXSTRUCT (ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.dwBackBufferCount = 1; if (pSDO->Caps.dwVidMemFree>=(pDDSD->dwWidth*pDDSD->dwHeight*(pDDSD->ddpfPixelFormat.dwRGBBitCount>>3))) { ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_VIDEOMEMORY;/* | DDSCAPS_LOCALVIDMEM;*/ } else { ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; } IERRSTRING ("DirectDraw", IDirectDraw7_CreateSurface(pSDO->pDevice, &ddsd, &pSDDB->Primary, NULL)); INITIALDXSTRUCT (pSDDB->Desc); IERRSTRING ("DirectDraw", IDirectDrawSurface7_GetSurfaceDesc (pSDDB->Primary, &pSDDB->Desc)); memset (&caps, 0, sizeof (caps)); if (pSDO->Caps.dwVidMemFree>=(pDDSD->dwWidth*pDDSD->dwHeight*(pDDSD->ddpfPixelFormat.dwRGBBitCount>>3))) caps.dwCaps = DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_BACKBUFFER | DDSCAPS_VIDEOMEMORY/* | DDSCAPS_LOCALVIDMEM*/; else caps.dwCaps = DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_BACKBUFFER; IERRSTRING ("DirectDraw", IDirectDrawSurface7_GetAttachedSurface(pSDDB->Primary, &caps, &pSDDB->Buffer)); The code creates a direct draw primary surface with an attached buffer surface. The strange problem is that sometimes the buffered surface is created with a different resolution then the primary surface. The screen would flip from one resolution surface to a different resolution surface. Directdraw wont allow to creat primary surface with the width and height specified at the DDSURFDESC2. Do you have any idea what can cause this? I would appreaciate help on this matter.

Share this post

Link to post
Share on other sites