Skip to main content
GameDev.net gamedev.net
🔒 Locked

Page Flipping

Started by DirectAndy8 May 22, 2002 at 12:21 PM 3 replies 250+ views
Original Post
DirectAndy8
DirectAndy8
OK... I''ve created a primary surface, and retrieved a back buffer surface from it. Then I lock the back buffer surface, do a load of drawing to it, and unlock the back buffer surface. Finally I call lpddsPrimary->Flip(NULL, DDFLIP_WAIT). This should be all I need to do, right? As I understand it, when I flip, the back buffer becomes the primary buffer - changing what''s on screen instantly - and the primary buffer becomes the back buffer, picking up it''s contents. However when I do it, flipping every frame, alternate frames show only half of the writing I do to the back buffer. It''s as though the flip simply switches which of the surfaces is shown, instead of doing what I understand to be page flipping (and what the docs say it does). So can anybody tell me how to fix this? Thanks!
Senses777
Senses777
the back and front video buffers are completely separate. When you flip, you do not change any surfaces at all. The pointer that points to the buffer simply switches to the backbuffer, and then that is displayed.

There is no copying of pixels or anything between the surfaces during a flip, and nothing is erased on either surface when you flip. (if you draw a circle to one, and a square to the other, you can flip back and forth and see both).

often, surfaces are destroyed and cleared for seemingly no reason. This is just what happens. Usually this only happens at the start of a program or when you alt tab out and then into the program (actually the surfaces are generally lost when you alt tab, so you have to recreate them).

hope this helps! .sen
"I want to make a simple MMORPG first" - Fenryl
DirectAndy8
DirectAndy8
OK... but surely when I write something to the back buffer, then flip it so that it is shown, the changes that I made to the back buffer have to be represented on what is now the back buffer or else I''ll just have to make exactly the same changes again, to what is now the back buffer? Which is surely pointless?
Carrot
Carrot
You need to update the back buffer each frame.

You state:
"...and the primary buffer becomes the back buffer, picking up it''s contents."

The primary buffer doesn''t pick up any contents from the back buffer. The back buffer needs to be reconstructed each frame (if you clear the buffer before drawing that is, which is usual).


Jason Zelos
Jason Zelos
If you are using surface blitting, or any of the other DX routines they automaticly lock the surface so you don't need to.

,Jay

[edited by - Jason Zelos on May 27, 2002 2:58:50 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.