Primary Surface errors
when im trying to create the primary surface (using directdraw with directx 7.0) i always get errors that it cant create the primary surface. is there anything wrong with my code? note: lpDD is the directdraw interface, which is created successfully
(SOURCE)
//DIRECTDRAW VARIABLES
LPDIRECTDRAW7 lpDD = NULL;
//Primary Surface
LPDIRECTDRAWSURFACE7 lpDDSPrimary = NULL;
//Back Buffer
LPDIRECTDRAWSURFACE7 lpDDSBack = NULL;
bool CreatePrimarySurface()
{
DDSURFACEDESC2 ddsd;
DDSCAPS2 ddscaps;
HRESULT ddrval;
// Create the primary surface with 1 back buffer
memset( &ddsd, 0, sizeof(ddsd) );
ddsd.dwSize = sizeof( ddsd );
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
ddrval = lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL );
if( ddrval != DD_OK )
{
lpDD->Release();
return(false);
}
// Get the pointer to the back buffer
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrval = lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);
if( ddrval != DD_OK )
{
lpDDSPrimary->Release();
lpDD->Release();
return(false);
}
return true;
}
(END SOURCE)
i code therefore i am.
What errors are you getting?
Have you included the Libraries?
Have you put #define INITGUID in your source?
instead of:
// Get the pointer to the back buffer
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrval = lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);
try:
// Get the pointer to the back buffer
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof( ddsd );
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrval = lpDDSPrimary->GetAttachedSurface(&ddsd, &lpDDSBack);
Dont know if that helps.
[edited by - Losec on February 2, 2003 7:18:45 AM]
Have you included the Libraries?
Have you put #define INITGUID in your source?
instead of:
// Get the pointer to the back buffer
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrval = lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);
try:
// Get the pointer to the back buffer
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof( ddsd );
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrval = lpDDSPrimary->GetAttachedSurface(&ddsd, &lpDDSBack);
Dont know if that helps.
[edited by - Losec on February 2, 2003 7:18:45 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement