"Flip" not the same as "Vwait : Flip False"?

BlitzPlus Forums/BlitzPlus Programming/"Flip" not the same as "Vwait : Flip False"?

Teddyfles(Posted 2003) [#1]
Hi,

I have a problem in my game Mr. Twinkle.
http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=teddyfles08192002180656&comments=no

Well, actually, I already solved the problem, but I don't understand why my solution works. Here's the deal:

The command "Flip" (or "Flip True") automaticly does a "Vwait" and waits for the next vertical blank event of the monitor. So, I assumed that I would get exactly the same effect using:
Vwait
Flip False
However, when I used "Flip" my game was just not 100% smooth somehow. So I fooled around a little and found out that by using "Vwait" and "Flip False" my game runs perfectly smooth. This seems odd to me, since I thought the two methods would do exactly the same thing.

So, my game runs smoothly now (also with 100% machine independent game speed :)), so I'm happy, but also very curious to why "Flip" doesn't seem to be doing the same thing as "Vwait".


Ross C(Posted 2003) [#2]
so what your saying is Vwait, doesn't do the same thing as Flip True?


Teddyfles(Posted 2003) [#3]
Basicly yes.

Flip True
doesn't do the same thing as
Vwait
Flip False
Which is not what I expected.


Teddyfles(Posted 2003) [#4]
You can use this program to test it:

Graphics 640, 480
SetBuffer BackBuffer()

While Not GetKey()
	Cls
	counter = counter + 1
	If MilliSecs() - timer >= 1000
		timer = MilliSecs()
		updates = counter
		counter = 0
	EndIf
	Text 10, 10, "Updates per second using 'Flip': "
	Text 10, 26, updates
	Text 10, 100, "Press any key to continue test..."
	Flip
Wend

While Not GetKey()
	Cls
	counter = counter + 1
	If MilliSecs() - timer >= 1000
		timer = MilliSecs()
		updates = counter
		counter = 0
	EndIf
	Text 10, 10, "Updates per second using 'Vwait : Flip False': "
	Text 10, 26, updates
	Text 10, 100, "Press any key to continue test..."
	VWait
	Flip False
Wend
End


Using "Flip" I get 50 fps and using "Vwait" and "Flip False" I get 85 fps, which is the correct number since my monitor has a refresh rate of 85Hz.

Also, this only happens in full screen. Windowed I get 85 in both cases.


Ross C(Posted 2003) [#5]
mmmm...strange, i get 86 fps in both cases :S


QuickSilva(Posted 2003) [#6]
I too experienced this then found this snippet in the docs, under the Flip command which explains why this happens. Hope this helps :)

However, it is worth noting that this setting applies to the graphics card only, and some graphics cards allow the user to disable the vertical blank event. Therefore, if you rely on Flip alone, the display may be corrupted on certain setups. The VWait command may be useful to you in this respect, as it forces the CPU to wait for the vertical blank (as opposed to the graphics card), and this cannot be disabled. Hence true silky smooth updates are best achieved using "VWait : Flip False".


Teddyfles(Posted 2003) [#7]
Joker, thanks for testing.
QuickSilva, thanks for the explination. That is exactly what I wanted to know. Although now I feel kind of stupid for not reading the docs more carefully. :)


QuickSilva(Posted 2003) [#8]
Thats OK, I never remembered seeing that part either ;)
Jason.


Mark Tiffany(Posted 2003) [#9]
Ooh, somebody found my rewritten flip description useful! That's actually been in the online docs for quite a while, but I think it may have only just got into the dowloadable docs paks. It is very useful to know, even if it will p*** off those people who thought they had disabled vertical blanks... ;-)