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
path: root/intern
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 /intern
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 'intern')
-rw-r--r--intern/ghost/GHOST_C-api.h13
-rw-r--r--intern/ghost/GHOST_IWindow.h13
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp13
-rw-r--r--intern/ghost/intern/GHOST_Window.h21
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp14
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.h13
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp22
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.h13
8 files changed, 122 insertions, 0 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index a92d0d33b65..aae90179be5 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -666,6 +666,19 @@ extern GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
extern GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle);
/**
+ * Sets the swap interval for swapBuffers.
+ * \param interval The swap interval to use.
+ * \return A boolean success indicator.
+ */
+extern GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int interval);
+
+/**
+ * Gets the current swap interval for swapBuffers.
+ * \return An integer.
+ */
+extern int GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle);
+
+/**
* Activates the drawing context of this window.
* \param windowhandle The handle to the window
* \return An intean success indicator.
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index a2d3e9b91fb..35577075263 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -205,6 +205,19 @@ public:
virtual GHOST_TSuccess swapBuffers() = 0;
/**
+ * Sets the swap interval for swapBuffers.
+ * \param interval The swap interval to use.
+ * \return A boolean success indicator.
+ */
+ virtual GHOST_TSuccess setSwapInterval(int interval) = 0;
+
+ /**
+ * Gets the current swap interval for swapBuffers.
+ * \return An integer.
+ */
+ virtual int getSwapInterval() = 0;
+
+ /**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index b73ff26c259..8d4498ed759 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -691,6 +691,19 @@ GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
return window->swapBuffers();
}
+GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int interval)
+{
+ GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
+
+ return window->setSwapInterval(interval);
+}
+
+int GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle)
+{
+ GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
+
+ return window->getSwapInterval();
+}
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 588de0911e3..77ee4db8543 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -67,6 +67,8 @@ public:
* virtual GHOST_TWindowOrder getOrder(void) = 0;
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
* virtual GHOST_TSuccess swapBuffers() = 0;
+ * virtual GHOST_TSuccess setSwapInterval() = 0;
+ * virtual int getSwapInterval() = 0;
* virtual GHOST_TSuccess activateDrawingContext() = 0;
* virtual GHOST_TSuccess invalidate() = 0;
*/
@@ -110,6 +112,8 @@ public:
* virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
* virtual GHOST_TSuccess swapBuffers() = 0;
+ * virtual GHOST_TSuccess setSwapInterval() = 0;
+ * virtual int getSwapInterval() = 0;
* virtual GHOST_TSuccess activateDrawingContext() = 0;
* virtual GHOST_TSuccess invalidate() = 0;
*/
@@ -205,6 +209,23 @@ public:
}
/**
+ * Sets the swap interval for swapBuffers.
+ * \param interval The swap interval to use.
+ * \return A boolean success indicator.
+ */
+ virtual GHOST_TSuccess setSwapInterval(int interval) {
+ return GHOST_kFailure;
+ }
+
+ /**
+ * Gets the current swap interval for swapBuffers.
+ * \return An integer.
+ */
+ virtual int getSwapInterval() {
+ return 0;
+ }
+
+ /**
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
*/
virtual void setAcceptDragOperation(bool canAccept);
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index b0d0b1a5b5d..c264686fbb1 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -648,6 +648,20 @@ GHOST_TSuccess GHOST_WindowWin32::swapBuffers()
return ::SwapBuffers(hDC) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
+GHOST_TSuccess GHOST_WindowWin32::setSwapInterval(int interval)
+{
+ if (!WGL_EXT_swap_control)
+ return GHOST_kFailure;
+ return wglSwapIntervalEXT(interval) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
+}
+
+int GHOST_WindowWin32::getSwapInterval()
+{
+ if (WGL_EXT_swap_control)
+ return wglGetSwapIntervalEXT();
+
+ return 0;
+}
GHOST_TSuccess GHOST_WindowWin32::activateDrawingContext()
{
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index 2fd1f5b37f4..6fdc963f30a 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -212,6 +212,19 @@ public:
virtual GHOST_TSuccess swapBuffers();
/**
+ * Sets the swap interval for swapBuffers.
+ * \param interval The swap interval to use.
+ * \return A boolean success indicator.
+ */
+ virtual GHOST_TSuccess setSwapInterval(int interval);
+
+ /**
+ * Gets the current swap interval for swapBuffers.
+ * \return An integer.
+ */
+ virtual int getSwapInterval();
+
+ /**
* Activates the drawing context of this window.
* \return Indication of success.
*/
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 25d7c181b68..3173736c2a5 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -30,6 +30,8 @@
*/
+#include <GL/glxew.h>
+
#include "GHOST_WindowX11.h"
#include "GHOST_SystemX11.h"
#include "STR_String.h"
@@ -1513,3 +1515,23 @@ endFullScreen() const
return GHOST_kSuccess;
}
+
+GHOST_TSuccess
+GHOST_WindowX11::
+setSwapInterval(int interval) {
+ if (!GLX_EXT_swap_control)
+ return GHOST_kFailure;
+ glXSwapIntervalEXT(m_display, m_window, interval);
+ return GHOST_kSuccess;
+}
+
+int
+GHOST_WindowX11::
+getSwapInterval() {
+ if (GLX_EXT_swap_control) {
+ unsigned int value;
+ glXQueryDrawable(m_display, m_window, GLX_SWAP_INTERVAL_EXT, &value);
+ return (int)value;
+ }
+ return 0;
+}
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index b8471b41a11..7cbdcdeec21 100644
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -235,6 +235,19 @@ public:
GHOST_TSuccess endFullScreen() const;
+ /**
+ * Sets the swap interval for swapBuffers.
+ * \param interval The swap interval to use.
+ * \return A boolean success indicator.
+ */
+ virtual GHOST_TSuccess setSwapInterval(int interval);
+
+ /**
+ * Gets the current swap interval for swapBuffers.
+ * \return An integer.
+ */
+ virtual int getSwapInterval();
+
protected:
/**
* Tries to install a rendering context in this window.