Jump to content
  • Advertisement
Sign in to follow this  
vinb

Trying to get a back buffer working

This topic is 4444 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

I am making a blackjack game, but in the process of experimenting, I fear I have royally messed things up. I get a nasty error (Unhandled exception at 0x0041dabf in BlackJack.exe: 0xC0000005: Access violation reading location 0x00000000.) when the program gets to this line:
ddrval = lpsCards->GetAttachedSurface(&ddscaps, &lpBackBuffer);
    // create the main DirectDraw object
    DirectDrawCreateEx( NULL, (VOID**)&lpDD, IID_IDirectDraw7, NULL );

    ddrval = lpDD->SetCooperativeLevel( hwnd, DDSCL_NORMAL );
    if( ddrval != DD_OK )
    {
        lpDD->Release();
        return(false);
    }

    // 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, &lpsCards, NULL);
    
    ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
    ddrval = lpsCards->GetAttachedSurface(&ddscaps, &lpBackBuffer);

I have been trying to follow multiple tutorials and I'm at the point where I think I'm just confusing myself (not hard to do). Is this the proper way to set up a primary surface with a back buffer?

Share this post


Link to post
Share on other sites
Advertisement
I've taken a couple of more whacks at it and I'm finding that I can't even create the primary surface...

if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpDD, IID_IDirectDraw7, NULL)))
return(0);

ddrval = lpDD->SetCooperativeLevel( hwnd, DDSCL_NORMAL );

DDRAW_INIT_STRUCT(ddsd);

ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount = 1;

ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;

// this fails for some reason
if (FAILED(lpDD->CreateSurface(&ddsd, &lpsCards, NULL)))
return(0);


Any idea why CreateSurface would fail?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!