Archived

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

Landi

Double Buffering

Recommended Posts

Hello, I am trying to create a double buffer for my game and when I looked at a tutorial I noticed it was a bit tricky. Maybe it was just the tutorial but I still can''t figure it out. I''m using Visual C++ 6.0, with Directx 8.0 and directdraw for my 2d game. my blit is set up like this: dd_obj.LoadBackSurface(hinstance,"whateversprite.bmp",x, y); dd_obj.DrawTransparent(hwnd, RGB(255,255,255)); where x,y locates the sprite on the screen. does anyone know an easy way to do the buffer, your help would be greatly appreciated. thanks PS. on an unrelated note, is it possible to load moving GIF files into C++ or do I have to animate them manually?

Share this post


Link to post
Share on other sites
You got it all wrong.

Double buffer is a name for a technique of using a secondary buffer that has the same exact dimension as your screen to avoid flickering. Your screen is the primary buffer, and the secondary buffer acts as a copy of your screen that will get flipped with the primary buffer.

What you did is to load the sprite to the memory, but that sprite is not the secondary buffer, it''s an offscreen surface. However, secondary buffer is also an offscreen surface but it''s tightly connected to the primary buffer which is the screen you see on your monitor. That''s why secondary buffer has the same size as your primary buffer (screen).

The trick of double buffering is to copy everything to the secondary buffer first, then flip it with the primary buffer to be presented to the user.

You know the trick of making a cartoon movie? Each piece of paper contains a frame, and then they are flipped to create an animation effect. Same thing with double buffering, but we don''t use as many papers cartoonists use. We only use two and recycle them.

Share this post


Link to post
Share on other sites
Thanks but I never intended the code for my blit to do the double buffering. I was just trying to show you how I set it up.
I want to know how to actually double buffer that specific code.
I know the theory but I want an example or specific case on how i can actually use it.

Thanks in advance for your help!

Share this post


Link to post
Share on other sites
This article might be useful: http://www.gamedev.net/reference/articles/article608.asp

quote:
Original post by Landi PS. on an unrelated note, is it possible to load moving GIF files into C++ or do I have to animate them manually?


AFAIK, you cannot reproduce animated GIF files using some utility function from DirectX. Your best option would be to load every frame of the GIF in a separate surface (or a big one, if you want) and animate it with your own code.

Hope that helps!

--Ignacio Liverotti
iliverotti@hotmail.com

Share this post


Link to post
Share on other sites
I am close to getting the thing to work, but the previous animations appear in the bitmap size box when I try to blit it.
If I don''t blit it it screws up the background

Share this post


Link to post
Share on other sites