Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2013-07-30 02:31:32 +0400
committerMitchell Stokes <mogurijin@gmail.com>2013-07-30 02:31:32 +0400
commit29f8dfd37a2fbf4190e551bef0b04ff1ae1fd7b6 (patch)
treeaf50623534adee419cecbbf6e0d8dd789409d266 /source/gameengine/GamePlayer/ghost
parent2840edba840382f0957c4963c3613c7836ac5979 (diff)
BGE: Adding vsync control. Users can enable vsync, disable vsync, or use adaptive vsync via UI options in the render properties, or by using the new Python method bge.render.setVsync(). Win32 and X11 support are done via EXT_swap_control. Support for using EXT_swap_control on OS X still needs to be added to Ghost.
Diffstat (limited to 'source/gameengine/GamePlayer/ghost')
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp7
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp14
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.h3
3 files changed, 23 insertions, 1 deletions
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index bedee5d9a47..6f7a87804dc 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -582,7 +582,12 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
m_canvas = new GPG_Canvas(window);
if (!m_canvas)
return false;
-
+
+ if (gm->vsync == VSYNC_ADAPTIVE)
+ m_canvas->SetSwapInterval(-1);
+ else
+ m_canvas->SetSwapInterval(gm->vsync); // VSYNC_OFF == 0, VSYNC_ON == 1, so this works
+
m_canvas->Init();
if (gm->flag & GAME_SHOW_MOUSE)
m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
index a1d00dad0e1..e0559385ee6 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
@@ -107,6 +107,20 @@ void GPG_Canvas::SwapBuffers()
}
}
+void GPG_Canvas::SetSwapInterval(int interval)
+{
+ if (m_window)
+ m_window->setSwapInterval(interval);
+}
+
+int GPG_Canvas::GetSwapInterval()
+{
+ if (m_window)
+ return m_window->getSwapInterval();
+
+ return 0;
+}
+
void GPG_Canvas::ResizeWindow(int width, int height)
{
if (m_window->getState() == GHOST_kWindowStateFullScreen)
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
index 6168d96b337..6e1f86cac0e 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
@@ -55,6 +55,9 @@ public:
virtual void SetMousePosition(int x, int y);
virtual void SetMouseState(RAS_MouseState mousestate);
virtual void SwapBuffers();
+ virtual void SetSwapInterval(int interval);
+ virtual int GetSwapInterval();
+
virtual int GetMouseX(int x) { return x; }
virtual int GetMouseY(int y) { return y; }
virtual float GetMouseNormalizedX(int x);