Skip to main content
gamedev.net
🔒 Locked

Back Surface Issues

Started by EnochDagor 4 replies 650+ views
Original Post
EnochDagor
EnochDagor
Ok, I first create my Primary Surface:
        
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSDBACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;

HRESULT hRet = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
if(hRet != DD_OK)
{
   return 1;
}
 [/source]

Then a little later I try to grab my attached surface:

[source]
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;

HRESULT ddrval = lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);
        
But, I get a DDERR_NOTFOUND error... What object is it referring to? All DDSurfaces I am using are valid... I got both declared as LPDIRECTDRAWSURFACE7. Any ideas? Edited by - EnochDagor on 9/16/00 1:16:00 PM Edited by - EnochDagor on 9/16/00 1:26:09 PM
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
Bigshot
Bigshot
The code you provided looks like it should work, although I think you meant to put:

ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;

instead of

ddsd.dwFlags = DDSD_CAPS | DDSDBACKBUFFERCOUNT;

You might be forgetting to do something in the initialization. Here''s the code I normally use right before I create the primary and back surfaces:

// create IDirectDrawdirectdraw interface 1.0 object
if (FAILED(DirectDrawCreate(NULL,&lpdd_temp,NULL)))
return(0);

// now query for IDirectDRAW7
if (FAILED(lpdd_temp->QueryInterface(IID_IDirectDraw7,
(LPVOID *)&lpdd)))
return(0);

// set cooperation level to requested mode
if (FAILED(lpdd->SetCooperativeLevel(main_window_handle,
DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN |
DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)))
return(0);

// set the display mode
if (FAILED(lpdd->SetDisplayMode(width,height,bpp,0,0)))
return(0);

Good luck!

Alex
EnochDagor
EnochDagor
I was under the impression that for DirectX 7.0 I didn''t need to create the first DirectDraw Object and that I could just use

HRESULT ddret = DirectDrawCreateEx(NULL, (LPVOID*)&lpDD, IID_IDirectDraw7, NULL);

Am I wrong? I will try it your way and see what I get...
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
Ironblayde
Ironblayde
That''s not the problem; using DirectDrawCreateEx() will work just fine.

-Ironblayde
 Aeon Software
"Your superior intellect is no match for our puny weapons!"
EnochDagor
EnochDagor
Yeah Alex, it didn''t work. So, I''m gonna stick with the DirectDrawCreateEx()....

I should also mention that this is being handled within a class that handles all the DDraw stuff.

The code that calls the Primary and Back surface creation is in the WinMain...

It looks like this:

DDRAWMANAGER DDraw;

DDraw->InitDD();
//I handle some error handling here
DDraw->InitDDSPrimary();
//Some more error handling
DDraw->InitDDSBack();
//Some more error handling (where the error is caught)

Now, the InitDD is your every day run of the mill DD initialization.

The Primary was described in my first post

The Back was described at the later part of my first post.

Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
EnochDagor
EnochDagor
Got it... I needed to add

ZeroMemory(&ddscaps, sizeof(ddscaps));

before I called the GetAttachedSurface...

Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.