I am attempting to change the default resolution of Windows Timer for Xojo, and Xojo doesn’t seem to respond to this global change. The current limitation is about 15 milliseconds (see Limitations On Microsoft Windows ). A time of 15 milliseconds has a maximum frames-per-second game refresh rate of about 62 fps which shows flickering of the screen. The reason for this change is to use the timer for refreshing graphics instead of requiring a thread for firing - which causes issues with accessing Windows1 for even the most basic of changes.
The default global timer limitation can be modified with the NTSetTimerResolution C++ command by using a Xojo Declare and an example program has been made which changes the resolution from 15,600 100ths of a nanosecond (15.6 milliseconds) to 9,000 100th of a millisecond (0.9 milliseconds) and an be downloaded here:
After running various Canvas and OpenGL examples with the lower millisecond setting (0.9 millisecond global refresh rate), there is no change with the default timer firing, and it remains at about 15.6 milliseconds instead of 0.9 milliseconds.
Is there something that I am missing, or that can be changed to modify the default firing of the timer in Xojo on Windows? I am open to suggestions
plus if your refresh rate exceeds that of the monitor you should not be able to percieve a flicker… for that matter, if your FPS exceeds even 24fps it should be hard to percieve it… since that is the retention period of most peoples eyes (and why movies were shot at that speed (on film)…digital is faster these days)
Thanks for the comments Dave. I seem to remember reading how the clock interrupt is related to the Intel chip, which has about a 2.81 GHz speed - thats alot of cycles per second. The NtSetTimerResolution is designed to modify the global timer resolution for media to allow programs to increase their updates for games and video. NtSetTimerResolution can be set to 0.5 milliseconds on my specific machine, instead of the default 15.6 ms.
I like where you are going with this. I have a 1920x1080 monitor, and the refresh rate of the hardware on an Mini Displayport using DVI is 240 frames per second, which is well above the 24 fps. The hardware doesn’t seem to be the issue, and when using a thread can provide very fast frames per second - Here is some of the test data from a previous post: Speed
Computer No Mouse Movement (fps) Mouse Movement (fps)
Surface Book (VGA) 1700-1900 2500-2800
Mac Mini (Late 2009) 50-61 56-61
Mac Mini (Late 2012) 60 61
ASUS 1000-2300 3100-3300
Surface Pro I 900-1400 1300-1500
The Windows computer seems to be able to have a high frames per second output, along with the ability to process and render code extremely fast. There seems to be something that I don’t understand with the Timer in Xojo that causes flickering - which is likely below the 24 frames per second that is mentioned. My thought (which may be incorrect) is to lower the refresh rate of the global timer from 15.6 milliseconds (62 fps) to 0.5 milliseconds (2000 fps).
I don’t know the answer, and it doesn’t hurt to ask. Thanks for your thoughts Dave, and it seems like there might be something else in the background of Xojo with the timer that I am not aware.
This could definitely be a possibility. I placed the NTSetTimerResolution code in the App.Open event before creating a timer in an attempt to change the timer resolution before other code begins, and there was no change. The resolution may need to be set earlier than that.