From b351db810df85d4ecf545fa2701ccb5f22d5a0d5 Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Sat, 19 Mar 2016 06:40:39 +0200 Subject: [PATCH] vsync is now default mode --- xmain_d2d.d | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/xmain_d2d.d b/xmain_d2d.d index 83dd4c0..9954254 100644 --- a/xmain_d2d.d +++ b/xmain_d2d.d @@ -17,6 +17,8 @@ */ module xmain_d2d is aliced; +//version = dont_use_vsync; + private: import core.atomic; import core.thread; @@ -661,8 +663,6 @@ enum MinFrameTime = 1000/60; // ~60 FPS void renderThread () { try { - version(use_vsync) {} else MonoTime ltt = MonoTime.currTime; - MonoTime curtime = MonoTime.currTime; lastthink = curtime; // for interpolator @@ -702,7 +702,11 @@ void renderThread () { // "video frames"; curtime should be set; return `true` if frame was processed; will fix `curtime` bool doVFrame () { - version(use_vsync) { + version(dont_use_vsync) { + // timer + enum doCheckTime = true; + } else { + // vsync __gshared bool prevLost = false; bool doCheckTime = vframeWasLost; if (vframeWasLost) { @@ -713,12 +717,10 @@ void renderThread () { } else { prevLost = false; } - } else { - enum doCheckTime = true; } if (doCheckTime) { if (curtime < nextvframe) return false; - version(use_vsync) {} else { + version(dont_use_vsync) { if (curtime > nextvframe) { auto overtime = cast(int)((curtime-nextvframe).total!"msecs"); if (overtime > 2500) { @@ -802,7 +804,6 @@ void renderThread () { for (;;) { if (sdwindow.closed) break; if (atomicLoad(diedie) > 0) break; - //{ import core.stdc.stdio; printf(" spent only %d msecs\n", cast(int)((time-ltt).total!"msecs")); } sleepAtMaxMsecs(100); } } @@ -962,10 +963,10 @@ void main (string[] args) { if (adr is null) assert(0); } } - version(use_vsync) { - sdwindow.vsync = true; - } else { + version(dont_use_vsync) { sdwindow.vsync = false; + } else { + sdwindow.vsync = true; } //sdwindow.useGLFinish = false; initOpenGL(); -- 2.11.4.GIT