DDraw Initiation
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
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 );
And remeber to flip the primary Surface to ge the back buffer.
prim->Flip( 0 , DDFLIP_WAIT );
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 );
And remeber to flip the primary Surface to ge the back buffer.
prim->Flip( 0 , DDFLIP_WAIT );
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?
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.
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.
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
Or maybe because you''re getting the sizeof DDSURFACEDESC instead of DDSURFACEDESC2, when setting dwSize?
THANKS DARRELL!!!!!!!!!!!!!!!!!!!!!!!
IT was the sizeof() thing, man what a dumb mistake, thanks man
IT was the sizeof() thing, man what a dumb mistake, thanks man
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement