Post by Roger Cabo on Dec 22, 2023 21:02:08 GMT 1
Hi everyone,
In the past I used the simple VSYNC or Vsync Address $387?! <-- but do not remember exactly.. but that does not work in windows since decades.
But how to get a fixed FPS timing?
Let's say I want to have 15,30,60,90,120,140,240?
+ How I get the current FPS setting from the Monitor vis API?
+ And we implement this to the d2dLib?
This doesn't work unfortunately!
How is D2EndDraw configured? DXGI_PRESENT_SYNC_INTERVAL ?
Would this be a common solution?
And how to calculate the Timer.DeltaTime for fixed timing animation?
I think that's important to know
In the past I used the simple VSYNC or Vsync Address $387?! <-- but do not remember exactly.. but that does not work in windows since decades.
But how to get a fixed FPS timing?
Let's say I want to have 15,30,60,90,120,140,240?
+ How I get the current FPS setting from the Monitor vis API?
+ And we implement this to the d2dLib?
This doesn't work unfortunately!
Function GetMonitorRefreshRate() As Integer
Dim devMode As DEVMODE
Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, ByRef lpDevMode As DEVMODE) As Boolean
devMode.dmSize = Len(DEVMODE)
If EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, devMode) Then
MsgBox devMode.dmDisplayFrequency
GetMonitorRefreshRate = devMode.dmDisplayFrequency
Else
GetMonitorRefreshRate = -1 ' Fehlerfall
End If
End Function
Type DEVMODE
dmDeviceName As String * 32
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * 32
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
How is D2EndDraw configured? DXGI_PRESENT_SYNC_INTERVAL ?
Would this be a common solution?
Dim TargetFrameRateMs# = 1000/60 // ... 60FPS anyhow from the current Monitor
Dim t#
Do
t#= Timer // Timer high precision
D2BeginDraw(win1RT);
D2Clear(D2C_ForestGreen);
... Draw
D2EndDraw();
t# = timer- t#
Sleep(TargetFrameRateMs# - t#)
DoEvents or PEEKEVENT ? // <---- ??
Loop Until anything
And how to calculate the Timer.DeltaTime for fixed timing animation?
I think that's important to know