Changing Default Resolution of Windows Timer To Increase Graphics Speed

Hello Everyone,

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:

Example 12-02 - Modifiy NtSetTimerResolution.

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 :slight_smile:

perhaps this helps?

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.

My suspicion would be that by the time you get a chance to make the call to change the resolution its far to late to alter what the framework is going to use

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.

A LOT of code has run by the time YOU get to “App.Open” :slight_smile:

Maybe we need an “App.OpenBeforeFrameworkIsLoaded” event? :wink:

You misspelled it
It should be App.YouCantLoadOrRunAnything BeforeTheFrameworksAreSetUp() event :slight_smile:

Ok, these comments answer my question. My assumption is that I’ll continue to use the Thread:Timer pair where appropriate.

Just thinking out loud, I wonder how a declare to the C++ timer would work? I’ll look at that another day.

Thanks folks.

Try TimerMBS. It works much faster on Windows. At least at 5ms.