Plea for a #Pragma DisableThreadAccessingUIException

Yes, this makes complete sense. At the measured speeds from the above test, everything was blurring together because it was too fast.

I think Sam has the right approach, and the reason to separate geometry calculations from drawing refreshes is to slow down Windows OS so that it is not drawing so fast. I had originally believed that the drawing was too slow.

The next step is to figure out how to slow down Xojo in Windows to make the drawing refreshes not appear to be studdering.

Why don’t you synchronize them with Ticks ? That should be simple enough.

HI Michel, Yes, that would work out very well.

Would It be acceptable to put this While-Wend tick-counter in the Window open event? The reason why I am asking is I don’t want to make the same mistake by putting the While-Wend loop in an area of the program that would cause known issues, such as a thread.

How did you set up your loop in your tests ? It would not take much to add the ticks sync in any loop, really. A simple

if Ticks > previousTicks then

would probably suffice.

I wonder if you could not actually place your loop in a 5 or 10 ms timer, so you would have the benefit of not freezing the UI as it happens in a while/wend without App.DoEvents (yik).

Thanks Michel

Actually I just verified the Windows timer, it does not go much under 16 ms, and sometimes over 22 ms. That makes it slightly too slow, since 60 frames per second is something around 17 ms. Xojo.Core.Timer is the same.

I would go for the loop. With some way to stop it of course.

I just tested it, and a timer-loop you mentioned renders smoother-looking graphics.

Yes the timer does seem to be just a little too slow for graphics. Thanks for the loop idea, and it looks like it will be a better option.

If you need precise timer, you can try my TimerMBS class:

http://www.monkeybreadsoftware.net/class-timermbs.shtml

Of course your timers are faster, Christian. But for a book, Eugene probably needs examples that do not require additional plugins.

[quote=295717:@Christian Schmitz]If you need precise timer, you can try my TimerMBS class:

http://www.monkeybreadsoftware.net/class-timermbs.shtml[/quote]

Just out of curiosity. Would it not be possible to make your own timer by using: Microseconds (http://documentation.xojo.com/index.php/Microseconds) Or some declares to Microsoft’s QueryPerformanceCounter (How to Time Code | Experts Exchange)

John, you asked right. The trick was to find a way to have a succession of events instead of a loop, because a loop would freeze the app.

This project is based on my idea of using invalidate inside the Paint event of a canvas in another thread started by Eugene, which had showed the ability for Xojo to trigger events in microseconds intervals. Could not locate that thread at the moment.

I have tried the following SuperTimer with periods of 1 ms. I am convinced if I had chosen a resolution in microseconds, it is possible to go under that. But for regular apps, that should be amply sufficient.

https://dl.dropboxusercontent.com/u/17407375/SuperTimer.zip

Eugene, I believe this will enable you to have a very smooth frame rate, while keeping the UI active.

Eugene, You might have a look on this site: https://forums.anandtech.com/threads/do-you-have-hpet-enabled-or-disabled.2362109/

About High Precision Event Timer (HPET https://en.wikipedia.org/wiki/High_Precision_Event_Timer ) if enabled or not in the bios,

Hi John. I am currently using the Microseconds timer which is providing a smoother framerate for animation. The GLSpeedTest example that I posted earlier uses this timer type.

Thanks for mentioning the HPET John because I didn’t know about it. I checked on my machines which are all Intel, and they are all enabled. A way to check if HPET is enabled without going into the BIOS, open Device Manager\System Devices\High precision event timer. Double-click on High precision event timer and click the Driver tab and see if it is enabled (for those who will check out this thread in the future). After running various programs with HPET enabled and disabled, I was not able to find any measureable or visual difference. I’ll keep this in mind for the future - thanks!

Thank you for sharing the Super Timer program Michel. I’ll try it on a few applications to see how it improves the stuttering issue.

Thank you for letting me know Christian, although I am not looking for a plugin solution at this time.