Original Post
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.