opengl: Add more checks and debugging info to SetSwapInterval.

This commit is contained in:
Alex 2022-12-03 00:06:27 +03:00
parent f9a36b9c91
commit 199e25f3f3
1 changed files with 29 additions and 2 deletions

View File

@ -28,6 +28,10 @@
#include <wx/glcanvas.h>
#include <wx/utils.h>
#ifdef _WIN32
#pragma optimize( "", off )
#endif
class GL_UTILS
{
public:
@ -107,9 +111,28 @@ public:
if( aVal == -1 && !wxGLCanvas::IsExtensionSupported( "WGL_EXT_swap_control_tear" ) )
aVal = 1;
wglSwapIntervalEXT( aVal );
const GLubyte* vendor = glGetString( GL_VENDOR );
const GLubyte* renderer = glGetString( GL_RENDERER );
return wglGetSwapIntervalEXT();
HDC hdc = wglGetCurrentDC();
HGLRC hglrc = wglGetCurrentContext();
if( hdc && hglrc )
{
// Mostly for debugging
wxString vendor_wx = vendor;
wxString renderer_wx = renderer;
int currentInterval = wglGetSwapIntervalEXT();
if( currentInterval != aVal )
{
wglSwapIntervalEXT( aVal );
currentInterval = wglGetSwapIntervalEXT();
}
return currentInterval;
}
}
#endif
@ -117,4 +140,8 @@ public:
}
};
#ifdef _WIN32
#pragma optimize( "", on )
#endif
#endif /* GL_CONTEXT_MANAGER_H */