Flipping Flip

Blitz3D Forums/Blitz3D Beginners Area/Flipping Flip

JBR(Posted 2003) [#1]
Hi, I'm using B+ and posted a while ago about what Flip does in B+. When it switches screens it wastes a significant amount of time copying from one screen to the other aswell as flipping.

I don't think this happens in Blitz2D (BlitzBasic).

I'm currently losing about 1/3 of the time for each frame.

I was looking around and found that commands in B+ can be 'overwritten' with new commands by using C. This is unfortunately beyond me.

I was wondering if anyone could write a new Flip command that only switches the screens.

If someone could, it would be much appreciated.
Marg


WolRon(Posted 2003) [#2]
I think you are missing the point of Flip (or I don't understand BlitzPlus (I don't have it)).
Flip does not copy any data. It only changes the reference to where the new graphical data should be read from when the screen is refreshed (either following a vsync in a fullscreen app or during a paint command in a windowed app).

Like I said, I don't have BlitzPlus nor do I know how it works, but I would find it shocking if Mark programmed it to work the way you describe.


JBR(Posted 2003) [#3]
Hi WolRon,

Flip should do as you say but on BlitzPlus it does this but also coppies data from one screen to the other so that both screens have the same data on each. This is what is annoying me; the fact I'm losing time with Flip doing more than it should.

Maybe Mark could comment on why B+ Flip was written this way.

Marg


keyboard(Posted 2003) [#4]
Maybe other things in your game loop are causing a problem... if you post the code in question, you might get an answer where you are losing time ?

Are you using Grabimage or Copyrect inside the game loop?

Are you using text commands? There is an issue witn some NVidia driver not implementing them correctly, though this has been fixed in late edtition drivers...


JBR(Posted 2003) [#5]
Hi keyboard, try this code. Let it run for a few seconds and then press escape. On my P3 - 600Mhz it says 57. This is really 5.7 millisecs. On my 60Hz screen a frame gets 16.67 per frame. See the problem! I think you have B2D, tell me what time it takes on yours.

Graphics 1024,768,16,0
SetBuffer BackBuffer()

frames% = 0 : time%=MilliSecs()

While Not KeyHit(1)
Flip False
frames% = frames% + 1
Wend

Color 255,255,255
Text 0,0, (MilliSecs()-time%)/(frames%/10)
Flip

FlushKeys
WaitKey()
End


Ross C(Posted 2003) [#6]
try this code and see what fps reading you get

graphics 800,600
setbuffer backbuffer()


while not keyhit(1)	

	cls
	
	If MilliSecs()<timer+1000 Then
								frame=frame+1
	Else
								fps=frame
								frame=0
								timer=MilliSecs()
	End If

	Text 0,0,"fps="+fps

	Rect 200,200,7,7
	
	Flip False
Wend
End


see what fps you get.


JBR(Posted 2003) [#7]
Hi joker,

I get 242 fps

What should I get?

Marg


keyboard(Posted 2003) [#8]
Hi Marg, I've been away, sorry not to answer...

I'm not sure this is achieving anything:

Text 0,0, (MilliSecs()-time%)/(frames%/10)


and measuring fps with flip false, I don't quite understand what that achieves, it disables frame synching, but why is that a good thing?

anyway, this is a fps timer, someone else posted the timer part

Graphics 800,600
SetBuffer BackBuffer()
ScreenFont = LoadFont("arial",24)
SetFont ScreenFont

While Not KeyHit(1)	
	Cls	
	Color 255,50,50	
	Rect 0,0,150,50		
	Gosub FrameCounter
	Color 255,255,255
	Text 20,20,"fps="+FPS		
	Flip
Wend

FreeFont ScreenFont
End

.FrameCounter
	Frame% = Frame%+1	
	If SecondTimerOn = False Then 
		OneSecond# = MilliSecs() + 1000
		StartFrame% = Frame%
		SecondTimerOn = True		
	Else 
		If MilliSecs() > OneSecond# Then
			SecondTimerOn = False
			FPS% = Frame%-StartFrame%	
		EndIf
	EndIf	
	Return


it gives me 100 fps in BlitzPlus and Blitz Basic 2D, maybe you can see what it gives you. Just to be sure, I timed fps in a number of game loops in Blitz+ and Blitz2D, by putting a timer in various sample games, and the FPS was exactly the same in both.

In my own game efforts, I've found that exe's compiled with Blitz+ run more smoothly on older systems, so I'm pretty happy with it overall...

hope this helps, and all the best :)


JBR(Posted 2003) [#9]
Hi, got an email back from Mark regarding what Flip does in B+.

He says that currently it does copy data from one to the other while flipping aswell. I think!

He says that some 'Graphics' flags will be added soon for 'flip semantics'.

Marg