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


DDraw procedures

Recommended Posts

To all the DDraw gurus out there Is there a generic checklist that you go through when initializing DDraw and setting up your images? I''ve seen this in other people''s code, just wanted (I guess) your opinions on a generic template of things I need to do or setup prior to using DDraw. More or less like a game init procedure. Thanks for your help, wanted to see how other people go through their game_inits() in their mind... ~ Boltimus ~

Share this post

Link to post
Share on other sites
1. Create DirectDraw object
2. Set cooperative level for DirectDraw object (DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN for full-screen apps, DDSCL_NORMAL for windowed apps)
3. Set the display mode (this can be done later)
4. Create the front buffer
5. Create the back buffer(s); if the app is windowed, the back buffer will be its own surface, otherwise, you'll create it from the front buffer
6. If this is a windowed app (or you want DirectDraw to perform automatic clipping), create a clipper
7. If you created a clipper, attach them to the appropriate buffers (front, back, or both)
8. Clear the front and/or back buffer(s) to get rid of the garbage

Loading images (only after initialization):
1. Load the image into memory
2. Create a surface appropriate to hold the image
3. Lock the surface; use the returned surface pointer, and the pitch (never width) and height dimensions to copy the image data to the surface
4. Free the image from memory

Of course, in all cases (except for de-initialization) you should always check the return values. Do not just use the if(result ==/!= DD_*) method since HRESULTs can contain multiple values; use the FAILED or SUCCEEDED macros and go to the uninitialize procedure if there was an error.

Releasing images (before de-initialization):
1. Release the surface

1. Release the clipper
2. If the app is windowed, release the back buffer
3. Release the front buffer (if the app is full-screen, this will also release the back buffer)
4. Release the DirectDraw object

Edited by - merlin9x9 on July 27, 2001 10:25:50 PM

Share this post

Link to post
Share on other sites