GL/Context: USe glXMakeContextCurrent() for GLX

This commit is contained in:
Connor McLaughlin 2022-11-23 19:17:58 +10:00
parent 0d178a2a9e
commit 7a30c9ea43

View File

@ -10,7 +10,7 @@ ContextGLX::ContextGLX(const WindowInfo& wi) : Context(wi) {}
ContextGLX::~ContextGLX() ContextGLX::~ContextGLX()
{ {
if (glXGetCurrentContext() == m_context) if (glXGetCurrentContext() == m_context)
glXMakeCurrent(GetDisplay(), None, nullptr); glXMakeContextCurrent(GetDisplay(), None, None, None);
if (m_context) if (m_context)
glXDestroyContext(GetDisplay(), m_context); glXDestroyContext(GetDisplay(), m_context);
@ -58,10 +58,6 @@ bool ContextGLX::Initialize(const Version* versions_to_try, size_t num_versions_
if (!CreateWindow(screen)) if (!CreateWindow(screen))
return false; return false;
} }
else
{
Panic("Create pbuffer");
}
for (size_t i = 0; i < num_versions_to_try; i++) for (size_t i = 0; i < num_versions_to_try; i++)
{ {
@ -90,7 +86,7 @@ bool ContextGLX::ChangeSurface(const WindowInfo& new_wi)
{ {
const bool was_current = (glXGetCurrentContext() == m_context); const bool was_current = (glXGetCurrentContext() == m_context);
if (was_current) if (was_current)
glXMakeCurrent(GetDisplay(), None, nullptr); glXMakeContextCurrent(GetDisplay(), None, None, None);
m_window.Destroy(); m_window.Destroy();
m_wi = new_wi; m_wi = new_wi;
@ -102,7 +98,7 @@ bool ContextGLX::ChangeSurface(const WindowInfo& new_wi)
return false; return false;
} }
if (was_current && !glXMakeCurrent(GetDisplay(), GetDrawable(), m_context)) if (was_current && !glXMakeContextCurrent(GetDisplay(), GetDrawable(), GetDrawable(), m_context))
{ {
Log_ErrorPrintf("Failed to make context current again after surface change"); Log_ErrorPrintf("Failed to make context current again after surface change");
return false; return false;
@ -126,12 +122,12 @@ bool ContextGLX::SwapBuffers()
bool ContextGLX::MakeCurrent() bool ContextGLX::MakeCurrent()
{ {
return (glXMakeCurrent(GetDisplay(), GetDrawable(), m_context) == True); return (glXMakeContextCurrent(GetDisplay(), GetDrawable(), GetDrawable(), m_context) == True);
} }
bool ContextGLX::DoneCurrent() bool ContextGLX::DoneCurrent()
{ {
return (glXMakeCurrent(GetDisplay(), None, nullptr) == True); return (glXMakeContextCurrent(GetDisplay(), None, None, None) == True);
} }
bool ContextGLX::SetSwapInterval(s32 interval) bool ContextGLX::SetSwapInterval(s32 interval)
@ -314,9 +310,9 @@ bool ContextGLX::CreateVersionContext(const Version& version, GLXContext share_c
if (make_current) if (make_current)
{ {
if (!glXMakeCurrent(GetDisplay(), GetDrawable(), m_context)) if (!glXMakeContextCurrent(GetDisplay(), GetDrawable(), GetDrawable(), m_context))
{ {
Log_ErrorPrint("glXMakeCurrent() failed"); Log_ErrorPrint("glXMakeContextCurrent() failed");
glXDestroyContext(GetDisplay(), m_context); glXDestroyContext(GetDisplay(), m_context);
m_context = nullptr; m_context = nullptr;
return false; return false;