Primary Surface errors

Started by
2 comments, last by Neen10do 21 years, 2 months ago
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.
----------------------i code therefore i am.Aero DX - Coming to a bored Monitor near you!
Advertisement
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]
hey, I think you need to make a clipper

.lick
what i had to do was change my window style... i would have had to create a clipper... but once i got it into fullscreen mode (because my window wasn''t set up properly), it worked.

i code therefore i am.
----------------------i code therefore i am.Aero DX - Coming to a bored Monitor near you!

This topic is closed to new replies.

Advertisement