equivalent of vwait?

BlitzMax Forums/BlitzMax Programming/equivalent of vwait?

Vorderman(Posted 2005) [#1]
I'm trying to get smooth sprite movement, but I can't. I've tried adapting the 2d timing code in the archives but it judders around - the sprites move smoothly for a fraction of a second, then jump a little bit to catch up. The best current windowed system just sets a 60hz timer and then waits for it at the end of the mainloop - at least this is consistantly jerky with no sudden catchups.

I have my monitor set to 75hz, and when running he progam fullscreen with the graphics command specifying 75hz it's really smooth, but tears like mad in the lower half of the screen, indicating that I really need a vwait-like command in there.

Anyone got a decent system for smooth 2d in BMax???? All I really want is a smooth 60fps / hz update.


ImaginaryHuman(Posted 2005) [#2]
Max should be automatically double-buffered so you should no be seeing tearing, I would think?

Also you should use Flip - it automatically synchronizes without any extra timing code.


Vorderman(Posted 2005) [#3]
I am using flip - my mainloop looks like this -
Graphics 1024,768,32,60
Global timer1 = CreateTimer(60)

'other setup here

While Not KeyDown(KEY_ESCAPE)
	Cls

      'game logic stuff here

      'render here

	FlushMem
	WaitTimer(timer1)
	Flip
Wend

End


but it's not very smooth - moving sprites across the screen is really rather rough.

Any ideas?

Does debug mode do something weird to the timing?


Robert Cummings(Posted 2005) [#4]
Check out the extended parameters for Graphics(). They were updated with 1.10.

The extended parameters allow you to control if flip will wait or not and so on... give it a whirl.

Btw, game logic should run at a set rate and WaitTimer shouldn't really be used...


ImaginaryHuman(Posted 2005) [#5]
You shouldn't need your own timer if you are using Flip like that because Flip has its own timer already.


Hotcakes(Posted 2005) [#6]
Then the game will run at different speeds if 75 hz couldn't be achieved. I know that's unlikely, but... really depends what you're aiming your target specs at I guess.

Voderman, assuming you try he extended parameters fish talk about and it doesn't work still, check your display properties (assuming you're on windows) advanced settings and make sure vertical sync is not forced off (maybe even force it on)...


JazzieB(Posted 2005) [#7]
If 75hz cannot be achieved in hardware, Max will handle the sync in software by using it's own internal timer instead. That's the default option, which can be changed in the Graphics command. If it has to be synced in software, then you may see some tearing, although I'm not sure if it just waits for the nearest VSync before flipping.


Hotcakes(Posted 2005) [#8]
If 75hz cannot be achieved in hardware, Max will handle the sync in software by using it's own internal timer instead.

That's assuming Max is told that it can't do it in hardware. If the drivers lie to Max (which could happen when overriding settings in the display controls too) then there's not a lot it can do about it!