Klepto's GetDelta() - Juddering

BlitzMax Modules Forums/MiniB3D/Klepto's GetDelta() - Juddering

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I have tested this code on both MacOS and Vista (both on a MacBook with BootCamp so the hardware is identical).

In both OS's I am seeing serious juddering with Flip -1, and slight juddering with Flip 0.

On MacOS it is almost perfect on Flip 0 but not quite. Vista seems to have spasms where juddering on Flip 0 goes from non-existent to noticable.

On Flip 0 I'm getting an FPS of about 900 on the Mac and 1300 on Vista. The FPS does fluctuate quite a bit - is this normal?

Is there something wrong with the code? Is it due to background tasks? A driver issue maybe? I should point out that the juddering isn't constant but why is it so bad on Flip -1?

Please have a look and let me know what you think.

SuperStrict
Import klepto.miniB3D

Graphics3D(800, 600, 32, 0, 60)
TGlobal.SetDeltaFPS(60)

Global cam:TCamera = CreateCamera()
CameraRange(cam,1,2000)
CameraZoom(cam, 1.8)
PositionEntity(cam,0,200,-1500)
		
Global light:TLight = CreateLight(1)

Global Gravity:Float = 0.65
Global f:Int = -1	' Flip mode

Global ball:TBall = TBall.CreateBall()		

Repeat
	ball.Update()
	UpdateWorld
	RenderWorld
	
	DrawText("FPS:"+Int(TGlobal.GetFPS()), 10, 10)
	
	If KeyHit(KEY_SPACE)
		f:+1
		If f = 1 Then f = -1
	End If
	
	Select f
	Case -1
		DrawText("Flip -1 (Space)", 10, 30)
		Flip -1
	Case 0	
		DrawText("Flip 0 (Space)", 10, 30)
		Flip 0
	End Select
	
Until KeyDown(KEY_ESCAPE)

Type TBall
	Field mesh:TMesh
	Field radius:Float
	Field x:Float
	Field y:Float
	Field z:Float
	Field xv:Float
	Field yv:Float
	Field zv:Float
	
	Function CreateBall:TBall()
		Local b:TBall = New TBall
		
		b.mesh = CreateSphere(16)
		b.radius = 50
		ScaleEntity(b.mesh, b.radius, b.radius, b.radius)
		EntityColor(b.mesh, 255, 255, 255)
		PositionEntity(b.mesh, 0, 10, 0)
		b.xv = 15
		b.yv = 0 '-10
		
		Return b
	End Function
	
	Method Update()
		Local delta:Double = TGlobal.GetDelta()
		
		' Move ball
		TranslateEntity(mesh, xv*delta, yv*delta, zv*delta)
		
		' Keep ball on screen
		If EntityX(mesh) > 800 Then PositionEntity(mesh, 800, EntityY(mesh), EntityZ(mesh)); xv=-xv
		If EntityX(mesh) < -800 Then PositionEntity(mesh, -800, EntityY(mesh), EntityZ(mesh)); xv=-xv
	End Method
	
EndType