mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Merge pull request #4847 from JakubValtar/fix-pgl-timer
Keep Windows timer resolution high for OpenGL sketches
This commit is contained in:
@@ -431,6 +431,20 @@ public class PSurfaceJOGL implements PSurface {
|
||||
|
||||
|
||||
protected void initAnimator() {
|
||||
if (PApplet.platform == PConstants.WINDOWS) {
|
||||
// Force Windows to keep timer resolution high by
|
||||
// sleeping for time which is not a multiple of 10 ms.
|
||||
// See section "Clocks and Timers on Windows":
|
||||
// https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks
|
||||
Thread highResTimerThread = new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(Long.MAX_VALUE);
|
||||
} catch (InterruptedException ignore) { }
|
||||
}, "HighResTimerThread");
|
||||
highResTimerThread.setDaemon(true);
|
||||
highResTimerThread.start();
|
||||
}
|
||||
|
||||
animator = new FPSAnimator(window, 60);
|
||||
drawException = null;
|
||||
animator.setUncaughtExceptionHandler(new GLAnimatorControl.UncaughtExceptionHandler() {
|
||||
|
||||
Reference in New Issue
Block a user