Exists a vertical blank variable accessible to the user while in normal Windows (windowed)?
Is possible wait for vertical blanking on windows?
Is possible wait for vertical blanking on windows?
I'm an old school coder (Amiga rulez!
) so... my question is:
Exists a vertical blank variable accessible to the user while in normal Windows (windowed)?
Exists a vertical blank variable accessible to the user while in normal Windows (windowed)?
Re: Is possible wait for vertical blanking on windows?
U can use OpenWindowScreen() with either #PB_Screen_WaitSynchronization or #PB_Screen_SmartSynchronization.Caronte3D wrote:I'm an old school coder (Amiga rulez!) so... my question is:
Exists a vertical blank variable accessible to the user while in normal Windows (windowed)?
(Opengl (if used directly) also has functions to enable vSync -> ex. wglSwapIntervalEXT() on Windows.)
Anyhow you will need additional timing on top of that since monitors may have different refresh rates.
Re: Is possible wait for vertical blanking on windows?
Thanks, Mijikai, but I hope (workaround?) something to use with "OpenWindow" can be done 
Re: Is possible wait for vertical blanking on windows?
The other option would be a timer to render at fixed intervals.
Tearing is not really a problem, its not uncommon to see games that have options to disable vSync.
Edit: Just had an idea (old ddraw!) and it worked - have fun
Code:
U might want to add some timers and some sort of delay/event to release some cpu time 
Tearing is not really a problem, its not uncommon to see games that have options to disable vSync.
Edit: Just had an idea (old ddraw!) and it worked - have fun
Code:
Code: Select all
;TINY VSYNC (DDRAW)
;AUTHOR: MIJIKAI
EnableExplicit
Procedure.i WaitForVerticalBlank();wait for vsync! / returns 1 on sucess 0 on failure / note: busy wait!
Static *ddraw.IDirectDraw
If Not *ddraw
If DirectDrawCreate_(#Null,@*ddraw,#Null) = #Null
If *ddraw\WaitForVerticalBlank($4,#Null) = #Null
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
Else
ProcedureReturn 0
EndIf
Else
If *ddraw\WaitForVerticalBlank($4,#Null) = #Null
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndIf
EndProcedure
Procedure.i Demo(Title.s = #Null$,Width.i = 600,Height.i = 400)
Protected wnd.i
Protected wnd_flags.i
Protected wnd_event.i
Protected wnd_exit.i
Protected sync.i
Protected clock.i
wnd_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
wnd = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,wnd_flags)
If wnd
WindowBounds(wnd,Width,Height,#PB_Ignore,#PB_Ignore)
Repeat
Repeat
wnd_event = WindowEvent()
If wnd_event = #PB_Event_CloseWindow
wnd_exit = #True
EndIf
Until wnd_event = #Null
;-------------------------------
clock = ElapsedMilliseconds()
sync = WaitForVerticalBlank()
Debug ElapsedMilliseconds() - clock
Debug sync
;-------------------------------
Until wnd_exit
CloseWindow(wnd)
EndIf
ProcedureReturn #Null
EndProcedure
Demo("VSYNC")
End
Re: Is possible wait for vertical blanking on windows?
Welcome ! I commit this code some years ago : viewtopic.php?f=12&t=36852
Re: Is possible wait for vertical blanking on windows?
Thanks both for the code examples, I will take a look and try to insert something like that on my own code 
