mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 16:49:58 -06:00
GLInterface: Destroy GLWin
Everything is now safely tucked inside each individual GLInterface.
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
||||
#include "DolphinWX/GLInterface/GLX.h"
|
||||
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
@ -26,7 +26,7 @@ void* cInterfaceGLX::GetFuncAddress(const std::string& name)
|
||||
|
||||
void cInterfaceGLX::Swap()
|
||||
{
|
||||
glXSwapBuffers(GLWin.dpy, GLWin.win);
|
||||
glXSwapBuffers(dpy, win);
|
||||
}
|
||||
|
||||
// Create rendering window.
|
||||
@ -58,26 +58,25 @@ bool cInterfaceGLX::Create(void *window_handle)
|
||||
GLX_DOUBLEBUFFER,
|
||||
None };
|
||||
|
||||
GLWin.dpy = XOpenDisplay(nullptr);
|
||||
GLWin.parent = (Window)window_handle;
|
||||
GLWin.screen = DefaultScreen(GLWin.dpy);
|
||||
dpy = XOpenDisplay(nullptr);
|
||||
int screen = DefaultScreen(dpy);
|
||||
|
||||
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
|
||||
glXQueryVersion(dpy, &glxMajorVersion, &glxMinorVersion);
|
||||
NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion);
|
||||
|
||||
// Get an appropriate visual
|
||||
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDbl);
|
||||
if (GLWin.vi == nullptr)
|
||||
vi = glXChooseVisual(dpy, screen, attrListDbl);
|
||||
if (vi == nullptr)
|
||||
{
|
||||
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl);
|
||||
if (GLWin.vi != nullptr)
|
||||
vi = glXChooseVisual(dpy, screen, attrListSgl);
|
||||
if (vi != nullptr)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Only single buffered visual!");
|
||||
}
|
||||
else
|
||||
{
|
||||
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDefault);
|
||||
if (GLWin.vi == nullptr)
|
||||
vi = glXChooseVisual(dpy, screen, attrListDefault);
|
||||
if (vi == nullptr)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Could not choose visual (glXChooseVisual)");
|
||||
return false;
|
||||
@ -88,20 +87,23 @@ bool cInterfaceGLX::Create(void *window_handle)
|
||||
NOTICE_LOG(VIDEO, "Got double buffered visual!");
|
||||
|
||||
// Create a GLX context.
|
||||
GLWin.ctx = glXCreateContext(GLWin.dpy, GLWin.vi, nullptr, GL_TRUE);
|
||||
if (!GLWin.ctx)
|
||||
ctx = glXCreateContext(dpy, vi, nullptr, GL_TRUE);
|
||||
if (!ctx)
|
||||
{
|
||||
PanicAlert("Unable to create GLX context.");
|
||||
return false;
|
||||
}
|
||||
|
||||
XWindow.CreateXWindow();
|
||||
XWindow.Initialize(dpy);
|
||||
|
||||
Window parent = (Window)window_handle;
|
||||
win = XWindow.CreateXWindow(parent, vi);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cInterfaceGLX::MakeCurrent()
|
||||
{
|
||||
bool success = glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx);
|
||||
bool success = glXMakeCurrent(dpy, win, ctx);
|
||||
if (success)
|
||||
{
|
||||
// load this function based on the current bound context
|
||||
@ -112,7 +114,7 @@ bool cInterfaceGLX::MakeCurrent()
|
||||
|
||||
bool cInterfaceGLX::ClearCurrent()
|
||||
{
|
||||
return glXMakeCurrent(GLWin.dpy, None, nullptr);
|
||||
return glXMakeCurrent(dpy, None, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -120,11 +122,11 @@ bool cInterfaceGLX::ClearCurrent()
|
||||
void cInterfaceGLX::Shutdown()
|
||||
{
|
||||
XWindow.DestroyXWindow();
|
||||
if (GLWin.ctx)
|
||||
if (ctx)
|
||||
{
|
||||
glXDestroyContext(GLWin.dpy, GLWin.ctx);
|
||||
XCloseDisplay(GLWin.dpy);
|
||||
GLWin.ctx = nullptr;
|
||||
glXDestroyContext(dpy, ctx);
|
||||
XCloseDisplay(dpy);
|
||||
ctx = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user