summaryrefslogtreecommitdiff
path: root/platform/windows/gl_manager_windows.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-11-16 00:29:19 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-11-16 00:29:19 +0100
commit5993209b2649c93b56789bfc243c5a6046ee77ce (patch)
tree585d9485d1cebd635bf2485a6fdda50eb92a9a7a /platform/windows/gl_manager_windows.cpp
parent29e2aa416240f6ff782852b10a794471c0b92c2d (diff)
parent58a9cfee80a6889dd72d0c937eab895df50dba61 (diff)
Merge pull request #68700 from clayjohn/GLES3-vsync
Set vsync on window creation when using GLES3
Diffstat (limited to 'platform/windows/gl_manager_windows.cpp')
-rw-r--r--platform/windows/gl_manager_windows.cpp59
1 files changed, 21 insertions, 38 deletions
diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp
index 900bca8258..5b39c56ea3 100644
--- a/platform/windows/gl_manager_windows.cpp
+++ b/platform/windows/gl_manager_windows.cpp
@@ -185,6 +185,10 @@ Error GLManager_Windows::_create_context(GLWindow &win, GLDisplay &gl_display) {
return ERR_CANT_CREATE;
}
+ if (!wglSwapIntervalEXT) {
+ wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
+ }
+
return OK;
}
@@ -293,50 +297,30 @@ void GLManager_Windows::swap_buffers() {
}
Error GLManager_Windows::initialize() {
- wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
- wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT");
- //glWrapperInit(wrapper_get_proc_address);
-
return OK;
}
-void GLManager_Windows::set_use_vsync(bool p_use) {
- /*
- static bool setup = false;
- static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr;
- static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = nullptr;
- static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr;
-
- if (!setup) {
- setup = true;
- String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
- if (extensions.find("GLX_EXT_swap_control") != -1) {
- glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalEXT");
- }
- if (extensions.find("GLX_MESA_swap_control") != -1) {
- glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalMESA");
- }
- if (extensions.find("GLX_SGI_swap_control") != -1) {
- glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalSGI");
- }
+void GLManager_Windows::set_use_vsync(DisplayServer::WindowID p_window_id, bool p_use) {
+ GLWindow &win = get_window(p_window_id);
+ GLWindow *current = _current_window;
+
+ if (&win != _current_window) {
+ window_make_current(p_window_id);
}
- int val = p_use ? 1 : 0;
- if (glXSwapIntervalMESA) {
- glXSwapIntervalMESA(val);
- } else if (glXSwapIntervalSGI) {
- glXSwapIntervalSGI(val);
- } else if (glXSwapIntervalEXT) {
- GLXDrawable drawable = glXGetCurrentDrawable();
- glXSwapIntervalEXT(x11_display, drawable, val);
- } else {
- return;
+
+ if (wglSwapIntervalEXT) {
+ win.use_vsync = p_use;
+ wglSwapIntervalEXT(p_use ? 1 : 0);
+ }
+
+ if (current != _current_window) {
+ _current_window = current;
+ make_current();
}
- use_vsync = p_use;
- */
}
-bool GLManager_Windows::is_using_vsync() const {
- return use_vsync;
+bool GLManager_Windows::is_using_vsync(DisplayServer::WindowID p_window_id) const {
+ return get_window(p_window_id).use_vsync;
}
HDC GLManager_Windows::get_hdc(DisplayServer::WindowID p_window_id) {
@@ -354,7 +338,6 @@ GLManager_Windows::GLManager_Windows(ContextType p_context_type) {
direct_render = false;
glx_minor = glx_major = 0;
- use_vsync = false;
_current_window = nullptr;
}