Jump to content
  • Advertisement


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

martin smith

John De Goes 3D Game Book DD Problem..

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

Hi Folks, I''ve been using Direct Draw for some months now without any problems. I''m well ?!*% off now, because I''ve hit a brick wall. Till now, my Direct Draw set up code has been lifted out of Andre''s Tricks book without problem. I''m re-writing my engine in C++ and I''m trying without success to use John De Goes C++ encapsulation of Direct Draw from chapter 4 of 3D Game Programming With C++. Here''s where it falls over: REDirectDrawSurface.StartAccess((LPVOID*)&videoBuffer) is called from my main loop. Where REDirectDrawSurface is a global object of type DirectDrawSurface from chapter 4 of the book. I can''t blame you for "chucking this question" if you''ve not seen the book...... The StartAccess method simply performs: DECLARATION: bool StartAccess ( LPVOID *Pointer, RECT *Rect = NULL ); DEFINITION: bool DirectDrawSurface::StartAccess ( LPVOID *Pointer, RECT *Rect ) { LPDIRECTDRAWSURFACE7 Backbuffer; DDSURFACEDESC2 SurfaceDesc; DDSCAPS2 SurfaceCaps; HRESULT Val; // Obtain a pointer to the surface''s memory: ZeroMemory ( &SurfaceDesc, sizeof ( DDSURFACEDESC2 ) ); SurfaceDesc.dwSize = sizeof ( DDSURFACEDESC2 ); if ( !Created ) return false; if ( Surface7->IsLost () != DD_OK ) { if ( FAILED ( Surface7->Restore () ) ) return false; ShouldRepaint = true; } // If the surface is a primary surface, make sure we // obtain a pointer to the backbuffer, since that is the // surface the application probably wants to write to: if ( PropSurfaceType == Primary ) { SurfaceCaps.dwCaps = DDSCAPS_BACKBUFFER; Val = Surface7->GetAttachedSurface ( &SurfaceCaps, &Backbuffer ); if ( FAILED ( Val ) ) return PrintDirectDrawError ( Val ); Val = Backbuffer->Lock ( Rect, &SurfaceDesc, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL ); } else { Val = Surface7->Lock ( Rect, &SurfaceDesc, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL ); } if ( FAILED ( Val ) ) return PrintDirectDrawError ( Val ); ( *Pointer ) = SurfaceDesc.lpSurface; return true; } but I get a DDERR_NOTFOUND at the Val = Surface7->GetAttachedSurface ( &SurfaceCaps, &Backbuffer ); line Surface7 is not null. I''ll be buggered senseless if I''m gonna waste the whole of tomorrow on this. I''ll just have to write my own Direct Draw encapsulation, but I''d sooner use John De Goe''s if I (read you!) can get it to work. Any reason why DD should complain on the GetAttachedSurface with a DDERR_NOTFOUND?! I must confess I find this type of question off-putting myself, as you''re probably assuming (rightly) that there''s an error in the code somewhere, and the above snippet may not be where it lies. Still, any ideas?! Thanks chaps and chapesses. Martin

Share this post

Link to post
Share on other sites
I don´t really know if this will help you, but hopefully...

When you create the primary surface what values does your
DDSURFACEDESC2.ddsCaps.dwCaps has?

Check the part about "Creating The Primary Surface" (page 49 (lower part) and page 50 (upper part)) in John De Goes book (3D Game Programming With C++) and see if you got that right... =)

Good luck / Freeman_swe

Share this post

Link to post
Share on other sites
Thanks for the reply.

I''ve left the De Goes code behind, and decided to spend today writing my own wrapper, admittely based on Andre''s Tricks text, thought using XXX7 instead of XXX4.

Need to finish the project yesterday, in order to demo it for a job application.

Thanks again,

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.

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!