Jump to content
  • Advertisement

Archived

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

cb007sax

DDraw Initiation

This topic is 5900 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
Advertisement
I think its in your window handle. maybe you should make a parameter for it.
And remeber to flip the primary Surface to ge the back buffer.

prim->Flip( 0 , DDFLIP_WAIT );

Share this post


Link to post
Share on other sites
I think its in your window handle. maybe you should make a parameter for it.
And remeber to flip the primary Surface to ge the back buffer.

prim->Flip( 0 , DDFLIP_WAIT );

Share this post


Link to post
Share on other sites
i''ve made the window variable global, nothing seems to be wrong, when i use GetLastError i get 6 which means invalid handle, what could be wrong?

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
it''s failing at the first create surface call, i did clear the surface description by using = {0}; and i have tried ZeroMemory with it. this is very weird

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!