Changeset - r24890:b3530a2e5759
[Not reviewed]
master
0 2 0
Michael Lutz - 3 years ago 2021-01-16 15:43:18
michi@icosahedron.de
Change: [Win32] Disable VSync for OpenGL by default.
2 files changed with 13 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/video/win32_v.cpp
Show inline comments
 
@@ -1325,12 +1325,13 @@ void VideoDriver_Win32GDI::PaintThread()
 

	
 
#ifndef PFD_SUPPORT_COMPOSITION
 
#	define PFD_SUPPORT_COMPOSITION 0x00008000
 
#endif
 

	
 
static PFNWGLCREATECONTEXTATTRIBSARBPROC _wglCreateContextAttribsARB = nullptr;
 
static PFNWGLSWAPINTERVALEXTPROC _wglSwapIntervalEXT = nullptr;
 
static bool _hasWGLARBCreateContextProfile = false; ///< Is WGL_ARB_create_context_profile supported?
 

	
 
/** Platform-specific callback to get an OpenGL funtion pointer. */
 
static OGLProc GetOGLProcAddressCallback(const char *proc)
 
{
 
	return reinterpret_cast<OGLProc>(wglGetProcAddress(proc));
 
@@ -1395,12 +1396,15 @@ static void LoadWGLExtensions()
 
				const char *wgl_exts = wglGetExtensionsStringARB(dc);
 
				/* Bind supported functions. */
 
				if (FindStringInExtensionList(wgl_exts, "WGL_ARB_create_context") != nullptr) {
 
					_wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
 
				}
 
				_hasWGLARBCreateContextProfile = FindStringInExtensionList(wgl_exts, "WGL_ARB_create_context_profile") != nullptr;
 
				if (FindStringInExtensionList(wgl_exts, "WGL_EXT_swap_control") != nullptr) {
 
					_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
 
				}
 
			}
 

	
 
			wglMakeCurrent(nullptr, nullptr);
 
			wglDeleteContext(rc);
 
		}
 
	}
 
@@ -1413,12 +1417,13 @@ static FVideoDriver_Win32OpenGL iFVideoD
 

	
 
const char *VideoDriver_Win32OpenGL::Start(const StringList &param)
 
{
 
	if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 32) return "Only 32bpp blitters supported";
 

	
 
	Dimension old_res = _cur_resolution; // Save current screen resolution in case of errors, as MakeWindow invalidates it.
 
	this->vsync = GetDriverParamBool(param, "vsync");
 

	
 
	LoadWGLExtensions();
 

	
 
	this->Initialize();
 
	this->MakeWindow(_fullscreen);
 

	
 
@@ -1484,12 +1489,19 @@ const char *VideoDriver_Win32OpenGL::All
 
		/* Old OpenGL or old driver, let's hope for the best. */
 
		rc = wglCreateContext(this->dc);
 
		if (rc == nullptr) return "Can't create OpenGL context";
 
	}
 
	if (!wglMakeCurrent(this->dc, rc)) return "Can't active GL context";
 

	
 
	/* Enable/disable Vsync if supported. */
 
	if (_wglSwapIntervalEXT != nullptr) {
 
		_wglSwapIntervalEXT(this->vsync ? 1 : 0);
 
	} else if (vsync) {
 
		DEBUG(driver, 0, "OpenGL: Vsync requested, but not supported by driver");
 
	}
 

	
 
	this->gl_rc = rc;
 
	return OpenGLBackend::Create(&GetOGLProcAddressCallback);
 
}
 

	
 
bool VideoDriver_Win32OpenGL::ToggleFullscreen(bool full_screen)
 
{
src/video/win32_v.h
Show inline comments
 
@@ -140,12 +140,13 @@ public:
 

	
 
	const char *GetName() const override { return "win32-opengl"; }
 

	
 
protected:
 
	HDC   dc;          ///< Window device context.
 
	HGLRC gl_rc;       ///< OpenGL context.
 
	bool  vsync;       ///< Enable VSync?
 

	
 
	uint8 GetFullscreenBpp() override { return 32; } // OpenGL is always 32 bpp.
 

	
 
	void Paint() override;
 
	void PaintThread() override {}
 

	
0 comments (0 inline, 0 general)