What does Flip really do?

BlitzMax Forums/BlitzMax Programming/What does Flip really do?

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Here's some code that perfectly illustrates it.

SuperStrict

Graphics 800,600, 0, 0
SetBlend alphablend

While Not KeyHit(KEY_J)
		
	Cls
	
	'Draw
	Local start:Int = MilliSecs()
	For Local count:Int = 1 To 1
		DrawRect 10, 10, 600, 480
	Next
	Local endtime:Int = MilliSecs()
	Print "Draw Time: "+(endtime - start)
	
	'FLIP	
	Local flipstart:Int = MilliSecs()
	Flip -1
	Local flipend:Int = MilliSecs()
	Print "Flip Time: "+(flipend - flipstart)
	
Wend


On the system I'm using at the moment (P4 2.2GHz, 32MB shared video RAM, 736MB RAM) that tells me that Flip is taking 8 millisecs, while the drawing takes 0. Debug mode off.

If I increase the number of rectangles to draw to 10, the drawing time remains 0 while the Flip increases to 34. 100 rectangles, you get a draw time of 0, a flip time of 292.

It's a strange result, as though everything's just waiting to be drawn at the flip instead of drawn to the backbuffer when I call DrawRect().

Edit: Which Dreamora seems to be pretty much confirming. Aha!

This does make it difficult to isolate which drawing commands are particularly slow, however. It seems I can't "time" anything individually, as they'll all come up pretty quickly and the effects won't show until flip.

Still, nice to know how Flip works.