Archived

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

DDraw Initiation

This topic is 5539 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

this is kind of sad, and i can''t believe it but i''m having trouble creating a surface in direct draw, here is my initiation code bool DD_OBJ::Init() { LPDIRECTDRAW temp_lpdd = NULL; if(FAILED(DirectDrawCreateEx(0, (void**)&lpdd, IID_IDirectDraw7, 0))) return false; if(FAILED(lpdd->SetCooperativeLevel(MainWindow.hwnd,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT))) return false; if(FAILED(lpdd->SetDisplayMode(1024,768,32,0,0))) return false; // Initiate Surfaces DDSURFACEDESC2 surfaceDesc = {0}; ZeroMemory(&surfaceDesc, sizeof(surfaceDesc)); surfaceDesc.dwSize = sizeof(DDSURFACEDESC); surfaceDesc.dwFlags = DDSD_BACKBUFFERCOUNT | DDSD_CAPS; surfaceDesc.dwBackBufferCount = 1; surfaceDesc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE; if(FAILED(lpdd->CreateSurface(&surfaceDesc,&primarySurface,NULL))) { return false; } surfaceDesc.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; if(FAILED(primarySurface->GetAttachedSurface(&(surfaceDesc.ddsCaps),&backSurface))) return false; HDC bSurfDC = NULL; backSurface->GetDC(&bSurfDC); RECT rect = {0,0,800,600}; FillRect(bSurfDC,&rect,(HBRUSH)GetStockObject(BLACK_BRUSH)); backSurface->ReleaseDC(bSurfDC); return true; } sorry for pasting so much, i have the stuff defined as LPDIRECTDRAW7 lpdd; IDirectDrawSurface7* primarySurface; IDirectDrawSurface7* backSurface; What am i doing wrong? Anyone who posts through this and took the time to actually read through the code i thank you so much, thank u for your time if u looked at it

Share this post


Link to post
Share on other sites
Where abouts is it failing?
If it is at the back buffer creation, then you may want to clear the surface description so you aren''t passing a back buffer count of 1.
Another possibility is a selection of an unsupported display mode.
Crow.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
THANKS DARRELL!!!!!!!!!!!!!!!!!!!!!!!
IT was the sizeof() thing, man what a dumb mistake, thanks man

Share this post


Link to post
Share on other sites