11-18-2023, 02:09 AM
Hello,
How I can draw smooth animation?
In the attached code, the X jumps or stutters as it moves from left to right.
Things I tried that have not improved the smoothness:
use _Limit 60 instead of the Wait function
Re-arrange Waits to be before or after _Display
The FPS measurement timer settles on 55.6 fps, which I find to be strange.
This is regardless of how I set the Vertical Sync mode in my GPU drivers.
My display refresh rate is set to 60.0 fps.
How I can draw smooth animation?
In the attached code, the X jumps or stutters as it moves from left to right.
Things I tried that have not improved the smoothness:
use _Limit 60 instead of the Wait function
Re-arrange Waits to be before or after _Display
The FPS measurement timer settles on 55.6 fps, which I find to be strange.
This is regardless of how I set the Vertical Sync mode in my GPU drivers.
My display refresh rate is set to 60.0 fps.
Code: (Select All)
'Issue I'm seeing is that I am not getting an expected 60 fps screen update.
' Defocus your eyes by looking at the caret: ^
' and watch the X trail across the screen as it misses or stutters.
' For some strange reason I get 55.6 frames per second regardless of vsync on or off in graphics drivers.
Dim Shared fps As Single
Dim Shared fpsLast As Single
Dim Shared X As Integer
_Title "Framerate check"
Screen _NewImage(640, 480, 32)
timerFps = _FreeTimer
On Timer(timerFps, 10) UpdateFps
fps = 0
Timer(timerFps) On
_Display 'this causes autodisplay=off
X = 1
Do:
Cls , _RGB32(28, 28, 22)
Call Render
Locate 1, 60: Print "FPS:";
If fpsLast = 0.0 Then
Print "wait"
Else
Print fpsLast
End If
'_Limit 60
Wait &H3DA, 8, 8
_Display
Wait &H3DA, 8
fps = fps + 1
Loop Until _KeyHit = 27
End
Sub Render
If X < 1 Then X = 1
If X > _Width / 8 Then X = 1
Locate 10, X
Print "X"
X = X + 1
Locate 11, _Width / 16
Print "^"
End Sub
Sub UpdateFps
fpsLast = fps / 10.0
fps = 0.0
End Sub