summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-06-05 19:14:33 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-06-05 19:14:33 -0300
commit2420e46b449f4c8acdfe48c765ea52fc3e860de7 (patch)
treea49df7158f20ee6dca044c8ff7d7e81c13d83073 /platform/x11
parent684a1207c0a08889be7024d5851c224877557053 (diff)
vsync support
-works on windows -may not work on X11, if so please fix -OSX does not seem to support disabling vsync
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/context_gl_x11.cpp11
-rw-r--r--platform/x11/context_gl_x11.h4
-rw-r--r--platform/x11/os_x11.cpp14
-rw-r--r--platform/x11/os_x11.h3
4 files changed, 32 insertions, 0 deletions
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp
index 9f987e1376..442adb5d88 100644
--- a/platform/x11/context_gl_x11.cpp
+++ b/platform/x11/context_gl_x11.cpp
@@ -176,6 +176,16 @@ int ContextGL_X11::get_window_height() {
return xwa.height;
}
+void ContextGL_X11::set_use_vsync(bool p_use) {
+ GLXDrawable drawable = glXGetCurrentDrawable();
+ glXSwapIntervalEXT(x11_display, drawable, p_use?1:0);
+ use_vsync=p_use;
+}
+bool ContextGL_X11::is_using_vsync() const {
+
+ return use_vsync;
+}
+
ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context) : x11_window(p_x11_window) {
@@ -189,6 +199,7 @@ ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,con
glx_minor=glx_major=0;
p = memnew( ContextGL_X11_Private );
p->glx_context=0;
+ use_vsync=false;
}
diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h
index c77fb3e333..4474542c0b 100644
--- a/platform/x11/context_gl_x11.h
+++ b/platform/x11/context_gl_x11.h
@@ -55,6 +55,7 @@ class ContextGL_X11 : public ContextGL {
bool direct_render;
int glx_minor,glx_major;
bool opengl_3_context;
+ bool use_vsync;
public:
virtual void release_current();
@@ -65,6 +66,9 @@ public:
virtual Error initialize();
+ virtual void set_use_vsync(bool p_use);
+ virtual bool is_using_vsync() const;
+
ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context);
~ContextGL_X11();
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 66723c0295..b089436a17 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1952,6 +1952,20 @@ String OS_X11::get_joy_guid(int p_device) const {
return input->get_joy_guid_remapped(p_device);
}
+void OS_X11::set_use_vsync(bool p_enable) {
+ if (context_gl)
+ return context_gl->set_use_vsync(p_enable);
+}
+
+bool OS_X11::is_vsnc_enabled() const {
+
+ if (context_gl)
+ return context_gl->is_using_vsync();
+
+ return true;
+}
+
+
void OS_X11::set_context(int p_context) {
XClassHint* classHint = NULL;
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 1369340b04..311f26d4d3 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -240,6 +240,9 @@ public:
virtual void set_context(int p_context);
+ virtual void set_use_vsync(bool p_enable);
+ virtual bool is_vsnc_enabled() const;
+
void run();
OS_X11();