Skip to main content
gamedev.net
🔒 Locked

Flipping

Started by kirk 1 reply 1k views
Original Post
kirk
kirk
The DDRAW Flip method exchanges the pointer of the BackBuffer with the pointer of the PrimarySurface. Why if I exchange them by hand he does not work? For example: void MyFlip() { pPrimary->Lock(); pBack->Lock(); . . . // retrieve pointers DWORD *Temp = lpBackPn; lpBackPn = lpPrimaryPn; lpPrimaryPn = Temp; pPrimary->Unlock(); pBack->Unlock(); }
Kylotan
Kylotan
All you are doing is grabbing copies of pointers to the memory. Just because you decide to copy the value of what was returned for the back buffer into a variable that you call the front buffer, and vice versa, has no effect on the video card whatsoever. All that changes is that you now have erroneous names for the buffers. Changing the names in your program doesn''t change anything on the video card. The DirectDraw flip method, on the other hand, tells the video card to start treating what was the back buffer as the front buffer, and vice versa.
Gorky
Gorky
Why you would want to do this is beyond me.

Adding to what Kylotan said, too make your own home grown flip routine, you would need to have pointers to pointers. That way when you dereference once, you can change what the pointer points to (vs. the data a.k.a. regular pointer)

It would be more like the following:
(Not tested or compiled!)


void MyFlip(DDsurface **front, DDsurface **back)
{
(*front)->Lock();
(*back)->Lock();

DDsurface **Temp = *lpBackPn;
*lpBackPn = *lpPrimaryPn;
*lpPrimaryPn = *Temp;

(*front)->Unlock();
(*back)->Unlock();

}


That should work.




Topic Locked

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

Sign in to reply to this topic.