Jump to content
  • Advertisement

Archived

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

Sponge99

Blitting to primary surface (simple...)

This topic is 6331 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 using DirectDraw from DX7, and I have a question about blitting (the ''blt'' function). The book I''m reading, "Tricks of the Windows...", tells me to use the function to do a colorfill straight to the primary buffer, so I do that and nothing happens, just a blank screen. But then I blit to the backbuffer and flip the surfaces, and it shows up. What is going wrong when I blit straight to the primary surface? Do I need to lock it or something?

Share this post


Link to post
Share on other sites
Advertisement
The colorfill technique only fills the related surface (your offscreen backbuffer) with the color you specify, which is why you are not seeing anything initially. The backbuffer is just a working surface to prepare what goes on the screen. Once you have blitted all your blits to the backbuffer you then flip it to the primary surface (the actual screen). You shouldnt blit to the primary surface in any situation unless your app is running in windowed mode and you are not using a backbuffer, reading and writing to and from the primary surface can also be very slow since its in video memory.

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
I forgot to mention..

I suspect the book is wrong when is says you should do a colorfill straight to the primary surface, doing this will cause flashing and will slow down your frame-rate, what its trying to tell you is that you should colorfill the primary surfaces'' backbuffer to clear its contents for the new frame.

At every frame:

1) Colorfill the backbuffer (if required).
2) Blit your sprites to the backbuffer.
3) Flip the backbuffer to the primary surface


  Downloads:  ZeroOne Realm

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!