summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/context_gl_win.cpp17
-rw-r--r--platform/windows/context_gl_win.h8
-rw-r--r--platform/windows/os_windows.cpp15
-rw-r--r--platform/windows/os_windows.h3
4 files changed, 42 insertions, 1 deletions
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp
index ab66b81421..fd9e895370 100644
--- a/platform/windows/context_gl_win.cpp
+++ b/platform/windows/context_gl_win.cpp
@@ -96,6 +96,20 @@ static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) {
}
*/
+void ContextGL_Win::set_use_vsync(bool p_use) {
+
+ if (wglSwapIntervalEXT) {
+ wglSwapIntervalEXT(p_use?1:0);
+ }
+ use_vsync=p_use;
+
+}
+
+bool ContextGL_Win::is_using_vsync() const {
+
+ return use_vsync;
+}
+
Error ContextGL_Win::initialize() {
@@ -184,7 +198,7 @@ Error ContextGL_Win::initialize() {
printf("Activated GL 3.1 context");
}
-
+ wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress ("wglSwapIntervalEXT");
// glWrapperInit(wrapper_get_proc_address);
return OK;
@@ -194,6 +208,7 @@ ContextGL_Win::ContextGL_Win(HWND hwnd,bool p_opengl_3_context) {
opengl_3_context=p_opengl_3_context;
hWnd=hwnd;
+ use_vsync=false;
}
ContextGL_Win::~ContextGL_Win() {
diff --git a/platform/windows/context_gl_win.h b/platform/windows/context_gl_win.h
index 055e0b2f51..e1ab6fb26a 100644
--- a/platform/windows/context_gl_win.h
+++ b/platform/windows/context_gl_win.h
@@ -49,6 +49,8 @@
#include <windows.h>
+typedef bool (APIENTRY *PFNWGLSWAPINTERVALEXTPROC) (int interval);
+
class ContextGL_Win : public ContextGL {
HDC hDC;
@@ -56,6 +58,10 @@ class ContextGL_Win : public ContextGL {
unsigned int pixel_format;
HWND hWnd;
bool opengl_3_context;
+ bool use_vsync;
+
+
+ PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
public:
@@ -69,6 +75,8 @@ public:
virtual Error initialize();
+ virtual void set_use_vsync(bool p_use);
+ virtual bool is_using_vsync() const;
ContextGL_Win(HWND hwnd,bool p_opengl_3_context);
~ContextGL_Win();
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 65ee39f4da..5e3dc438d0 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2269,6 +2269,21 @@ String OS_Windows::get_joy_guid(int p_device) const {
return input->get_joy_guid_remapped(p_device);
}
+void OS_Windows::set_use_vsync(bool p_enable) {
+
+ if (gl_context)
+ gl_context->set_use_vsync(p_enable);
+}
+
+bool OS_Windows::is_vsnc_enabled() const{
+
+ if (gl_context)
+ return gl_context->is_using_vsync();
+
+ return true;
+}
+
+
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
key_event_pos=0;
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 6dd5b78bfd..509d76abbf 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -283,6 +283,9 @@ public:
virtual bool is_joy_known(int p_device);
virtual String get_joy_guid(int p_device) const;
+ virtual void set_use_vsync(bool p_enable);
+ virtual bool is_vsnc_enabled() const;
+
OS_Windows(HINSTANCE _hInstance);
~OS_Windows();