• Advertisement

Archived

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

Page flipping question...

This topic is 6347 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''m in the process of working on my first Direct X demo and i''m having a small problem that I cant seem to figure out. I am creating a starfield scrolling accross the screen as part of the demo and each star appears twice as if I am seeing the last two frames of the sequence at the same time. I am using a single back buffer, clearing the back buffer and drawing the new frame before flipping the page and locking the frame rate to 30fps. I can only assume that i''m doing something wrong with the page flipping since I am sure that I onlt draw each particle once. Are there any quirks of using one back buffer for page flipping in Dirext X that i might not be aware of? Cheers, -Forxl

Share this post


Link to post
Share on other sites
Advertisement
Yes, I clear the back buffer every frame. I tried stopping the demo in mid animation and confirmed that i''m only drawing one of every particle onto the back buffer but when it''s running it appears like there are two.

-Forxl

Share this post


Link to post
Share on other sites
make sure you have the backbuffer propley setup using GetAttatchedSurface, and when you render make sure you are rendering to the backbuffer, then flipping via the primary surface.

Share this post


Link to post
Share on other sites
It's important to understand exactly how page flipping works. At the very beggining, lets say *prim_buffer points to the primary buffer, and *back_buffer points to the back buffer. At first, you'd write to *back_buffer (the back buffer) and then flip. WHEN YOU FLIP, it changes *back_buffer to point to the primary buffer and *prim_buffer to point to the back buffer . Remember, we associated *prim_buffer with the primary buffer. Whatever is in the primary buffer (whatever *prim_buffer points to) is what's rendered, so the back buffer is rendered, since *prim_buffer points to the back buffer. Next frame, clear *prim_buffer and write to that. When the flip occurs, *prim_buffer points to the primary buffer, and *back_buffer points to the back buffer. This procedure alternates. Your problem is that you're writing to the SAME buffer each time, even though it's only the back buffer every other frame. Understand what I'm saying? It's confusing, yes, but it's very fast.

Edited by - Zipster on September 2, 2000 7:41:55 PM

Share this post


Link to post
Share on other sites
Here''s my 2 cents...
If you are completely burned out on flipping then just allocate memory for your backbuffer via malloc or new and use that as a back buffer until you get sick of the bad performance.. it''s just an alternate suggestion.

Share this post


Link to post
Share on other sites

  • Advertisement