guzza
asked on
CreateSuface failing
Will somebody please tell me what's wrong with this. CreateSurface is
returning DDERR_INVALIDPARAMS. I'm trying to create a single surface to
display a picture. I'm using the Cygnus GNU-Win32 compiler (beta 18) and
need the code to be in C. I've looked at all the sample code I can find
and can't figure out what's wrong.
LPDIRECTDRAWSURFACE lpDDSPrimary;
LPDIRECTDRAW lpDD;
HRESULT ddrval;
DDSURFACEDESC ddsd;
DDSCAPS ddscaps;
.
.
ddrval = DirectDrawCreate(NULL,&lpD D,NULL);
ddrval = lpDD->lpVtbl->SetCooperati veLevel(lp DD,hWnd,DD SCL_EXCLUS IVE |
DDSCL_FULLSCREEN);
ddrval = lpDD->lpVtbl->SetDisplayMo de(lpDD,64 0,480,8);
memset(&ddsd,0,sizeof(ddsd ));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
ddrval = lpDD->lpVtbl->CreateSurfac e(lpDD,&dd sd,&lpDDSP rimary,NUL L);
if (ddrval != DD_OK)
{
lpDD->lpVtbl->Release(lpDD );
return FALSE;
}
Thanks in advance...
Nick Gallimore
returning DDERR_INVALIDPARAMS. I'm trying to create a single surface to
display a picture. I'm using the Cygnus GNU-Win32 compiler (beta 18) and
need the code to be in C. I've looked at all the sample code I can find
and can't figure out what's wrong.
LPDIRECTDRAWSURFACE lpDDSPrimary;
LPDIRECTDRAW lpDD;
HRESULT ddrval;
DDSURFACEDESC ddsd;
DDSCAPS ddscaps;
.
.
ddrval = DirectDrawCreate(NULL,&lpD
ddrval = lpDD->lpVtbl->SetCooperati
DDSCL_FULLSCREEN);
ddrval = lpDD->lpVtbl->SetDisplayMo
memset(&ddsd,0,sizeof(ddsd
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
ddrval = lpDD->lpVtbl->CreateSurfac
if (ddrval != DD_OK)
{
lpDD->lpVtbl->Release(lpDD
return FALSE;
}
Thanks in advance...
Nick Gallimore
ASKER
Doesn't make a difference.
Just add more flags. Don't expect CreateSurface to automatically creates a surface matching the current screen mode.
ASKER
Any ideas/suggestions as to which ones to try? I tried adding DDSD_BACKBUFFERCOUNT, DDSD_ALPHABITDEPTH and DDSD_PIXELFORMAT, but nothing changed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ddrval = lpDD->lpVtbl->SetDisplayMo
memset(&ddsd,0,sizeof(ddsd
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD
ddsd.dwHeight=480; ddsd.dwWidth=640;
ddsd.ddsCaps.dwCaps = DDSC