set canvas fps inside a window

BlitzMax Forums/MaxGUI Module/set canvas fps inside a window

hub(Posted 2007) [#1]
Hi
i place a canvas inside a window.
Now how to set the canvaw fps refresh rate ? (if i want fix it to 60 fps). CreateTimer 60 and next EVENT_TIMERTICK ?
Thanks to post a code sample ! (I've a refesh problem for my game editor when i display pixmaps )
Many thanks !


Dreamora(Posted 2007) [#2]
No you can not set the refresh rate.
In windowed mode, Windows defines it and normally it is already 60 FPS.

This means: just call flip when you get a gadgetrepaint event normally.


hub(Posted 2007) [#3]
you can't ? Why not with this code ?

Global Timer:TTimer = CreateTimer(60)

While WaitEvent()
	
	Select EventID()
			
	
		Case EVENT_TIMERTICK
		
			SetGraphics CanvasGraphics(Canvas)
			Cls
			SetColor 255,255,255


			
			Flip
		
			
		Case EVENT_WINDOWCLOSE
			Exit
			
	
	End Select
Wend



ImaginaryHuman(Posted 2007) [#4]
Refresh rate on the desktop usually has to match that of the desktop display mode, so if your desktop is 60Hz then the vertical blank will be at 60hz in the hardware, so then when Max tries to sync with the vblank (if you ask it to) it will have to be the desktop's default, you can't really have different hz rates for each canvas at the same time. That said, you can use your own timer as shown and ask for the canvas to be refreshed when you want it to - but note it will still wait for the next vertical blank unless you flip 0 - and if you flip 0 you will get tearing. So you can only approximate your hz rate if you do it in software.