Jump to content
  • Advertisement
Sign in to follow this  
biscuitz

Page Flipping

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

Advertisement
you can use an offscreen buffer where you draw in, and then copy that buffer to your window, to avoid flicker.
use CreateCompatibleDC to create offscreen DC, then select a bitmap in it, and use BitBlt to copy to window DC. google for working examples.

*but* it might be wiser to use something like OpenGL, also for 2D stuff. it handles the page flipping for you, and it will make your program portable and easier to switch to 3D..

Share this post


Link to post
Share on other sites
I know I'm using a permanent double buffer right now. Just wondering if it's possible (and how) to page flip without OGL/DX.

Share this post


Link to post
Share on other sites
Quote:
Original post by biscuitz
I know I'm using a permanent double buffer right now. Just wondering if it's possible (and how) to page flip without OGL/DX.
Why would you want to page flip? Double buffering provides exactly the same benefits and should be plenty fast.

As far as I'm aware, it's not possible, but I wouldn't be surprised to discover that there is an obscure not-used-since-Win3.1 function to do page flipping in the GUI.

Share this post


Link to post
Share on other sites
Quote:
Original post by mrMagnetic
you can use an offscreen buffer where you draw in, and then copy that buffer to your window, to avoid flicker.
use CreateCompatibleDC to create offscreen DC, then select a bitmap in it, and use BitBlt to copy to window DC. google for working examples.

*but* it might be wiser to use something like OpenGL, also for 2D stuff. it handles the page flipping for you, and it will make your program portable and easier to switch to 3D..
I would also reccomend using OpenGL or DirectX (don't know if it's possible in GDI). Btw, that is double buffering which, as I understand, is different than page flipping.

Edit: sorry, didn't see the bit about anti OGL/DX

Share this post


Link to post
Share on other sites
Quote:
Original post by DigiDude
[Btw, that is double buffering which, as I understand, is different than page flipping.
Yeah, page flipping is a form of double buffering. Page flipping is where you store a pointer to the current screen, and when you want to update, instead of copying the data from one screen to another you just change the pointer to point at your second screen.

As far as I know, this isn't possible in plain GDI, since you need to be fullscreen to do that since you need control over the entire screen in order to flip buffers.
From what I've been able to determine, Win32 doesn't do what you may expect and give each window a unique surface and copy each window surface to the real desktop screen all the time. It seems to just let each window have pretty much direct access to one part of the real desktop. Which means no page flipping within windows. That's one reason you can't use GetDC() on a window that isn't in focus - you get whatever is where the window should be. Well, I did the last time I tried [smile]

Share this post


Link to post
Share on other sites
No, you can't do page flipping with GDI. You have to do a blt from an offscreen surface instead.

Supporting page flipping was probably one of the main reasons DirectDraw was invented. Use that if you don't want to use full-on DX.

Share this post


Link to post
Share on other sites
Thanks guys [smile] I'll consider using DirectDraw in case I need faster fps. (I'm trying to keep size/requirements down)

Share this post


Link to post
Share on other sites
Do bear in mind though that DirectDraw is now deprecated, there is little hardware support on newer cards and I believe it has been dumped completely from DirectX 10.

Direct3D 9 is a cleaner interface than the old DirectDraw 7 one and with ID3DXSprite, it is not too complex to use it for 2D graphics.

If you are approaching DirectX for the first time, you'd be advised to forget DirectDraw and just look into the newer DirectX Graphics.

Share this post


Link to post
Share on other sites
Quote:
Original post by biscuitz
[...](I'm trying to keep size/requirements down)
Use OpenGL quads to draw your sprites. You could even make a rather simple library based on OpenGL to handle it all for you (so your code still looks like the GDI code for the most part), and OpenGL doesn't require anything besides video card drivers (meaning no large redistributable).
You could also use an already-made library like SDL to handle it all for you.

However, unless you need advanced features (such as translucency or arbitrary rotation), GDI with double buffering really should be fast enough.

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!