CGLXManager: Use GLX window correctly

fixes #17
This commit is contained in:
sfan5 2021-03-12 17:47:00 +01:00
parent 0335a52479
commit 57ff34b1ed

@ -296,6 +296,10 @@ bool CGLXManager::generateSurface()
CurrentContext.OpenGLLinux.GLXWindow=GlxWin; CurrentContext.OpenGLLinux.GLXWindow=GlxWin;
} }
else
{
CurrentContext.OpenGLLinux.GLXWindow=CurrentContext.OpenGLLinux.X11Window;
}
return true; return true;
} }
@ -353,13 +357,14 @@ bool CGLXManager::activateContext(const SExposedVideoData& videoData, bool resto
{ {
if (videoData.OpenGLLinux.X11Display && videoData.OpenGLLinux.X11Context) if (videoData.OpenGLLinux.X11Display && videoData.OpenGLLinux.X11Context)
{ {
if (!glXMakeCurrent((Display*)videoData.OpenGLLinux.X11Display, videoData.OpenGLLinux.X11Window, (GLXContext)videoData.OpenGLLinux.X11Context)) if (!glXMakeCurrent((Display*)videoData.OpenGLLinux.X11Display, videoData.OpenGLLinux.GLXWindow, (GLXContext)videoData.OpenGLLinux.X11Context))
{ {
os::Printer::log("Context activation failed."); os::Printer::log("Context activation failed.");
return false; return false;
} }
else else
{ {
CurrentContext.OpenGLLinux.GLXWindow = videoData.OpenGLLinux.GLXWindow;
CurrentContext.OpenGLLinux.X11Window = videoData.OpenGLLinux.X11Window; CurrentContext.OpenGLLinux.X11Window = videoData.OpenGLLinux.X11Window;
CurrentContext.OpenGLLinux.X11Display = videoData.OpenGLLinux.X11Display; CurrentContext.OpenGLLinux.X11Display = videoData.OpenGLLinux.X11Display;
} }
@ -367,13 +372,14 @@ bool CGLXManager::activateContext(const SExposedVideoData& videoData, bool resto
else else
{ {
// in case we only got a window ID, try with the existing values for display and context // in case we only got a window ID, try with the existing values for display and context
if (!glXMakeCurrent((Display*)PrimaryContext.OpenGLLinux.X11Display, videoData.OpenGLLinux.X11Window, (GLXContext)PrimaryContext.OpenGLLinux.X11Context)) if (!glXMakeCurrent((Display*)PrimaryContext.OpenGLLinux.X11Display, videoData.OpenGLLinux.GLXWindow, (GLXContext)PrimaryContext.OpenGLLinux.X11Context))
{ {
os::Printer::log("Context activation failed."); os::Printer::log("Context activation failed.");
return false; return false;
} }
else else
{ {
CurrentContext.OpenGLLinux.GLXWindow = videoData.OpenGLLinux.GLXWindow;
CurrentContext.OpenGLLinux.X11Window = videoData.OpenGLLinux.X11Window; CurrentContext.OpenGLLinux.X11Window = videoData.OpenGLLinux.X11Window;
CurrentContext.OpenGLLinux.X11Display = PrimaryContext.OpenGLLinux.X11Display; CurrentContext.OpenGLLinux.X11Display = PrimaryContext.OpenGLLinux.X11Display;
} }
@ -425,7 +431,7 @@ void CGLXManager::destroyContext()
bool CGLXManager::swapBuffers() bool CGLXManager::swapBuffers()
{ {
glXSwapBuffers((Display*)CurrentContext.OpenGLLinux.X11Display, CurrentContext.OpenGLLinux.X11Window); glXSwapBuffers((Display*)CurrentContext.OpenGLLinux.X11Display, CurrentContext.OpenGLLinux.GLXWindow);
return true; return true;
} }