Use proper functions and checks for OpenGL VSYNC.
The vsync has to be {dis,en}abled before a ROM is loaded or we need to restart the output module to apply it. We also support MESA based installations (Intel HD Graphics, AMD/ATI and Nouveau) on Linux.
This commit is contained in:
parent
2ba0d316cd
commit
ed8a9af250
|
@ -133,7 +133,7 @@ void GameArea::LoadGame(const wxString& name)
|
||||||
|
|
||||||
if (!pfn.IsFileReadable()) {
|
if (!pfn.IsFileReadable()) {
|
||||||
pfn.SetExt(wxT("ups"));
|
pfn.SetExt(wxT("ups"));
|
||||||
|
|
||||||
if (!pfn.IsFileReadable()) {
|
if (!pfn.IsFileReadable()) {
|
||||||
pfn.SetExt(wxT("bps"));
|
pfn.SetExt(wxT("bps"));
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ void GameArea::LoadGame(const wxString& name)
|
||||||
int size = 0x2000000 < rom_size ? 0x2000000 : rom_size;
|
int size = 0x2000000 < rom_size ? 0x2000000 : rom_size;
|
||||||
applyPatch(pfn.GetFullPath().mb_str(), &rom, &size);
|
applyPatch(pfn.GetFullPath().mb_str(), &rom, &size);
|
||||||
// that means we no longer really know rom_size either <sigh>
|
// that means we no longer really know rom_size either <sigh>
|
||||||
|
|
||||||
gbaUpdateRomSize(size);
|
gbaUpdateRomSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2219,34 +2219,53 @@ void GLDrawingPanel::DrawingPanelInit()
|
||||||
#endif
|
#endif
|
||||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
// non-portable vsync code
|
// non-portable vsync code
|
||||||
#if defined(__WXGTK__) && defined(GLX_SGI_swap_control)
|
#if defined(__WXGTK__)
|
||||||
static PFNGLXSWAPINTERVALSGIPROC si = NULL;
|
static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL;
|
||||||
|
static PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA = NULL;
|
||||||
|
|
||||||
if (!si)
|
char* glxQuery = (char*)glXQueryExtensionsString(glXGetCurrentDisplay(), 0);
|
||||||
si = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddress((const GLubyte*)"glxSwapIntervalSGI");
|
|
||||||
|
|
||||||
if (si)
|
if (strstr(glxQuery, "GLX_SGI_swap_control") != NULL)
|
||||||
si(vsync);
|
{
|
||||||
|
glXSwapIntervalSGI = reinterpret_cast<PFNGLXSWAPINTERVALSGIPROC>(glXGetProcAddress(reinterpret_cast<const unsigned char*>("glXSwapIntervalSGI")));
|
||||||
|
|
||||||
#else
|
if (glXSwapIntervalSGI)
|
||||||
#if defined(__WXMSW__) && defined(WGL_EXT_swap_control)
|
glXSwapIntervalSGI(vsync);
|
||||||
static PFNWGLSWAPINTERVALEXTPROC si = NULL;
|
else
|
||||||
|
systemScreenMessage(_("Failed to set glXSwapIntervalSGI"));
|
||||||
|
}
|
||||||
|
else if (strstr(glxQuery, "GLX_MESA_swap_control") != NULL)
|
||||||
|
{
|
||||||
|
glXSwapIntervalMESA = reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(glXGetProcAddress(reinterpret_cast<const unsigned char*>("glXSwapIntervalMESA")));
|
||||||
|
|
||||||
if (!si)
|
if (glXSwapIntervalMESA)
|
||||||
si = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
|
glXSwapIntervalMESA(vsync);
|
||||||
|
else
|
||||||
|
systemScreenMessage(_("Failed to set glXSwapIntervalMESA"));
|
||||||
|
}
|
||||||
|
#elif defined(__WXMSW__)
|
||||||
|
typedef char* (*wglext)();
|
||||||
|
wglext wglGetExtensionsString = (wglext)wglGetProcAddress("wglGetExtensionsString");
|
||||||
|
if (wglGetExtensionsString == NULL || strstr(wglGetExtensionsString(), "WGL_EXT_swap_control") == 0) {
|
||||||
|
if (wglGetExtensionsString == NULL)
|
||||||
|
systemScreenMessage(_("No support for wglGetExtensionsString"));
|
||||||
|
else
|
||||||
|
systemScreenMessage(_("No support for WGL_EXT_swap_control"));
|
||||||
|
}
|
||||||
|
|
||||||
if (si)
|
typedef bool (*PFNWGLSWAPINTERVALEXTPROC)(int);
|
||||||
si(vsync);
|
static PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
|
||||||
|
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
|
||||||
#else
|
if (wglSwapIntervalEXT)
|
||||||
#ifdef __WXMAC__
|
wglSwapIntervalEXT(vsync);
|
||||||
|
else
|
||||||
|
systemScreenMessage(_("Failed to set wglSwapIntervalEXT"));
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
int swap_interval = vsync ? 1 : 0;
|
int swap_interval = vsync ? 1 : 0;
|
||||||
CGLContextObj cgl_context = CGLGetCurrentContext();
|
CGLContextObj cgl_context = CGLGetCurrentContext();
|
||||||
CGLSetParameter(cgl_context, kCGLCPSwapInterval, &swap_interval);
|
CGLSetParameter(cgl_context, kCGLCPSwapInterval, &swap_interval);
|
||||||
#else
|
#else
|
||||||
//#warning no vsync support on this platform
|
systemScreenMessage(_("No VSYNC available on this platform"));
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue