(view as text)
diff --git a/Source/Core/DolphinWX/Src/GLInterface.h b/Source/Core/DolphinWX/Src/GLInterface.h
index 9ef6c9f..d06cee7 100644
--- a/Source/Core/DolphinWX/Src/GLInterface.h
+++ b/Source/Core/DolphinWX/Src/GLInterface.h
@@ -35,20 +35,14 @@ typedef struct {
EGLDisplay egl_dpy;
int x, y;
unsigned int width, height;
-#elif defined(__APPLE__)
- NSView *cocoaWin;
- NSOpenGLContext *cocoaCtx;
#elif defined(HAVE_X11) && HAVE_X11
int screen;
Window win;
Window parent;
// dpy used for glx stuff, evdpy for window events etc.
// evdpy is to be used by XEventThread only
- Display *dpy, *evdpy;
+ Display *evdpy;
XVisualInfo *vi;
- GLXContext ctx;
- XSetWindowAttributes attr;
- std::thread xEventThread;
int x, y;
unsigned int width, height;
#endif
diff --git a/Source/Core/DolphinWX/Src/GLInterface/AGL.cpp b/Source/Core/DolphinWX/Src/GLInterface/AGL.cpp
index 1068e87..878aa70 100644
--- a/Source/Core/DolphinWX/Src/GLInterface/AGL.cpp
+++ b/Source/Core/DolphinWX/Src/GLInterface/AGL.cpp
@@ -28,7 +28,7 @@
void cInterfaceAGL::Swap()
{
- [GLWin.cocoaCtx flushBuffer];
+ [cocoaCtx flushBuffer];
}
// Create rendering window.
@@ -38,12 +38,12 @@ bool cInterfaceAGL::Create(void *&window_handle)
int _tx, _ty, _twidth, _theight;
Host_GetRenderWindowSize(_tx, _ty, _twidth, _theight);
- GLWin.cocoaWin = (NSView*)(((wxPanel*)window_handle)->GetHandle());
+ cocoaWin = (NSView*)(((wxPanel*)window_handle)->GetHandle());
// Enable high-resolution display support.
- [GLWin.cocoaWin setWantsBestResolutionOpenGLSurface:YES];
+ [cocoaWin setWantsBestResolutionOpenGLSurface:YES];
- NSWindow *window = [GLWin.cocoaWin window];
+ NSWindow *window = [cocoaWin window];
float scale = [window backingScaleFactor];
_twidth *= scale;
@@ -61,21 +61,21 @@ bool cInterfaceAGL::Create(void *&window_handle)
return false;
}
- GLWin.cocoaCtx = [[NSOpenGLContext alloc]
+ cocoaCtx = [[NSOpenGLContext alloc]
initWithFormat: fmt shareContext: nil];
[fmt release];
- if (GLWin.cocoaCtx == nil) {
+ if (cocoaCtx == nil) {
ERROR_LOG(VIDEO, "failed to create context");
return false;
}
- if (GLWin.cocoaWin == nil) {
+ if (cocoaWin == nil) {
ERROR_LOG(VIDEO, "failed to create window");
return false;
}
- [window makeFirstResponder:GLWin.cocoaWin];
- [GLWin.cocoaCtx setView: GLWin.cocoaWin];
+ [window makeFirstResponder:cocoaWin];
+ [cocoaCtx setView: cocoaWin];
[window makeKeyAndOrderFront: nil];
return true;
@@ -83,7 +83,7 @@ bool cInterfaceAGL::Create(void *&window_handle)
bool cInterfaceAGL::MakeCurrent()
{
- [GLWin.cocoaCtx makeCurrentContext];
+ [cocoaCtx makeCurrentContext];
return true;
}
@@ -97,15 +97,15 @@ bool cInterfaceAGL::ClearCurrent()
// Close backend
void cInterfaceAGL::Shutdown()
{
- [GLWin.cocoaCtx clearDrawable];
- [GLWin.cocoaCtx release];
- GLWin.cocoaCtx = nil;
+ [cocoaCtx clearDrawable];
+ [cocoaCtx release];
+ cocoaCtx = nil;
}
void cInterfaceAGL::Update()
{
- NSWindow *window = [GLWin.cocoaWin window];
- NSSize size = [GLWin.cocoaWin frame].size;
+ NSWindow *window = [cocoaWin window];
+ NSSize size = [cocoaWin frame].size;
float scale = [window backingScaleFactor];
size.width *= scale;
@@ -118,7 +118,7 @@ void cInterfaceAGL::Update()
s_backbuffer_width = size.width;
s_backbuffer_height = size.height;
- [GLWin.cocoaCtx update];
+ [cocoaCtx update];
}
diff --git a/Source/Core/DolphinWX/Src/GLInterface/AGL.h b/Source/Core/DolphinWX/Src/GLInterface/AGL.h
index 565d593..f489b85 100644
--- a/Source/Core/DolphinWX/Src/GLInterface/AGL.h
+++ b/Source/Core/DolphinWX/Src/GLInterface/AGL.h
@@ -34,6 +34,9 @@ public:
void Shutdown();
void Update();
+private:
+ NSView *cocoaWin;
+ NSOpenGLContext *cocoaCtx;
};
#endif
diff --git a/Source/Core/DolphinWX/Src/GLInterface/GLX.cpp b/Source/Core/DolphinWX/Src/GLInterface/GLX.cpp
index 22b472d..bcf5e66 100644
--- a/Source/Core/DolphinWX/Src/GLInterface/GLX.cpp
+++ b/Source/Core/DolphinWX/Src/GLInterface/GLX.cpp
@@ -38,7 +38,7 @@ void cInterfaceGLX::SwapInterval(int Interval)
void cInterfaceGLX::Swap()
{
- glXSwapBuffers(GLWin.dpy, GLWin.win);
+ glXSwapBuffers(dpy, GLWin.win);
}
// Create rendering window.
@@ -77,28 +77,28 @@ bool cInterfaceGLX::Create(void *&window_handle)
GLX_DOUBLEBUFFER,
None };
- GLWin.dpy = XOpenDisplay(0);
+ dpy = XOpenDisplay(0);
GLWin.evdpy = XOpenDisplay(0);
GLWin.parent = (Window)window_handle;
- GLWin.screen = DefaultScreen(GLWin.dpy);
+ GLWin.screen = DefaultScreen(dpy);
if (GLWin.parent == 0)
- GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen);
+ GLWin.parent = RootWindow(dpy, GLWin.screen);
- 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);
+ GLWin.vi = glXChooseVisual(dpy, GLWin.screen, attrListDbl);
if (GLWin.vi == NULL)
{
- GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl);
+ GLWin.vi = glXChooseVisual(dpy, GLWin.screen, attrListSgl);
if (GLWin.vi != NULL)
{
ERROR_LOG(VIDEO, "Only single buffered visual!");
}
else
{
- GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDefault);
+ GLWin.vi = glXChooseVisual(dpy, GLWin.screen, attrListDefault);
if (GLWin.vi == NULL)
{
ERROR_LOG(VIDEO, "Could not choose visual (glXChooseVisual)");
@@ -110,8 +110,8 @@ bool cInterfaceGLX::Create(void *&window_handle)
NOTICE_LOG(VIDEO, "Got double buffered visual!");
// Create a GLX context.
- GLWin.ctx = glXCreateContext(GLWin.dpy, GLWin.vi, 0, GL_TRUE);
- if (!GLWin.ctx)
+ ctx = glXCreateContext(dpy, GLWin.vi, 0, GL_TRUE);
+ if (!ctx)
{
PanicAlert("Unable to create GLX context.");
return false;
@@ -136,12 +136,12 @@ bool cInterfaceGLX::MakeCurrent()
XMoveResizeWindow(GLWin.evdpy, GLWin.win, GLWin.x, GLWin.y,
GLWin.width, GLWin.height);
#endif
- return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx);
+ return glXMakeCurrent(dpy, GLWin.win, ctx);
}
bool cInterfaceGLX::ClearCurrent()
{
- return glXMakeCurrent(GLWin.dpy, None, NULL);
+ return glXMakeCurrent(dpy, None, NULL);
}
@@ -149,12 +149,12 @@ bool cInterfaceGLX::ClearCurrent()
void cInterfaceGLX::Shutdown()
{
XWindow.DestroyXWindow();
- if (GLWin.ctx)
+ if (ctx)
{
- glXDestroyContext(GLWin.dpy, GLWin.ctx);
- XCloseDisplay(GLWin.dpy);
+ glXDestroyContext(dpy, ctx);
+ XCloseDisplay(dpy);
XCloseDisplay(GLWin.evdpy);
- GLWin.ctx = NULL;
+ ctx = NULL;
}
}
diff --git a/Source/Core/DolphinWX/Src/GLInterface/GLX.h b/Source/Core/DolphinWX/Src/GLInterface/GLX.h
index 2e8bde1..0fece5d 100644
--- a/Source/Core/DolphinWX/Src/GLInterface/GLX.h
+++ b/Source/Core/DolphinWX/Src/GLInterface/GLX.h
@@ -29,6 +29,9 @@ class cInterfaceGLX : public cInterfaceBase
{
private:
cX11Window XWindow;
+
+ Display *dpy;
+ GLXContext ctx;
public:
friend class cX11Window;
void SwapInterval(int Interval);
diff --git a/Source/Core/DolphinWX/Src/GLInterface/WGL.cpp b/Source/Core/DolphinWX/Src/GLInterface/WGL.cpp
index 62a4438..37de533 100644
--- a/Source/Core/DolphinWX/Src/GLInterface/WGL.cpp
+++ b/Source/Core/DolphinWX/Src/GLInterface/WGL.cpp
@@ -11,8 +11,6 @@
#include "WGL.h"
#include "EmuWindow.h"
-static HDC hDC = NULL; // Private GDI Device Context
-static HGLRC hRC = NULL; // Permanent Rendering Context
void cInterfaceWGL::SwapInterval(int Interval)
{
diff --git a/Source/Core/DolphinWX/Src/GLInterface/WGL.h b/Source/Core/DolphinWX/Src/GLInterface/WGL.h
index 0252698..42e7dba 100644
--- a/Source/Core/DolphinWX/Src/GLInterface/WGL.h
+++ b/Source/Core/DolphinWX/Src/GLInterface/WGL.h
@@ -26,6 +26,10 @@ public:
void Update();
bool PeekMessages();
+
+private:
+ HDC hDC = NULL; // Private GDI Device Context
+ HGLRC hRC = NULL; // Permanent Rendering Context
};
#endif
diff --git a/Source/Core/DolphinWX/Src/GLInterface/X11_Util.cpp b/Source/Core/DolphinWX/Src/GLInterface/X11_Util.cpp
index e3ea3f3..ef8ca43 100644
--- a/Source/Core/DolphinWX/Src/GLInterface/X11_Util.cpp
+++ b/Source/Core/DolphinWX/Src/GLInterface/X11_Util.cpp
@@ -22,9 +22,9 @@
#if USE_EGL
bool cXInterface::ServerConnect(void)
{
- GLWin.dpy = XOpenDisplay(NULL);
+ dpy = XOpenDisplay(NULL);
- if (!GLWin.dpy)
+ if (!dpy)
return false;
return true;
@@ -37,7 +37,7 @@ bool cXInterface::Initialize(void *config)
int num_visuals;
EGLint vid;
- if (!GLWin.dpy) {
+ if (!dpy) {
printf("Error: couldn't open X display\n");
return false;
}
@@ -49,7 +49,7 @@ bool cXInterface::Initialize(void *config)
/* The X window visual must match the EGL config */
visTemplate.visualid = vid;
- GLWin.vi = XGetVisualInfo(GLWin.dpy, VisualIDMask, &visTemplate, &num_visuals);
+ GLWin.vi = XGetVisualInfo(dpy, VisualIDMask, &visTemplate, &num_visuals);
if (!GLWin.vi) {
printf("Error: couldn't get X visual\n");
exit(1);
@@ -64,10 +64,10 @@ bool cXInterface::Initialize(void *config)
GLWin.evdpy = XOpenDisplay(NULL);
GLWin.parent = GLWin.win;
- GLWin.screen = DefaultScreen(GLWin.dpy);
+ GLWin.screen = DefaultScreen(dpy);
if (GLWin.parent == 0)
- GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen);
+ GLWin.parent = RootWindow(dpy, GLWin.screen);
/* Set initial projection/viewing transformation.
* We can't be sure we'll get a ConfigureNotify event when the window
@@ -80,7 +80,7 @@ bool cXInterface::Initialize(void *config)
void *cXInterface::EGLGetDisplay(void)
{
- return eglGetDisplay(GLWin.dpy);
+ return eglGetDisplay(dpy);
}
void *cXInterface::CreateWindow(void)
@@ -88,24 +88,24 @@ void *cXInterface::CreateWindow(void)
Atom wmProtocols[1];
// Setup window attributes
- GLWin.attr.colormap = XCreateColormap(GLWin.evdpy,
+ attr.colormap = XCreateColormap(GLWin.evdpy,
GLWin.parent, GLWin.vi->visual, AllocNone);
- GLWin.attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask;
- GLWin.attr.background_pixel = BlackPixel(GLWin.evdpy, GLWin.screen);
- GLWin.attr.border_pixel = 0;
+ attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask;
+ attr.background_pixel = BlackPixel(GLWin.evdpy, GLWin.screen);
+ attr.border_pixel = 0;
// Create the window
GLWin.win = XCreateWindow(GLWin.evdpy, GLWin.parent,
GLWin.x, GLWin.y, GLWin.width, GLWin.height, 0,
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
- CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr);
+ CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &attr);
wmProtocols[0] = XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", True);
XSetWMProtocols(GLWin.evdpy, GLWin.win, wmProtocols, 1);
XSetStandardProperties(GLWin.evdpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL);
XMapRaised(GLWin.evdpy, GLWin.win);
XSync(GLWin.evdpy, True);
- GLWin.xEventThread = std::thread(&cXInterface::XEventThread, this);
+ xEventThread = std::thread(&cXInterface::XEventThread, this);
// Control window size and picture scaling
GLInterface->SetBackBufferDimensions(GLWin.width, GLWin.height);
@@ -116,9 +116,9 @@ void cXInterface::DestroyWindow(void)
{
XDestroyWindow(GLWin.evdpy, GLWin.win);
GLWin.win = 0;
- if (GLWin.xEventThread.joinable())
- GLWin.xEventThread.join();
- XFreeColormap(GLWin.evdpy, GLWin.attr.colormap);
+ if (xEventThread.joinable())
+ xEventThread.join();
+ XFreeColormap(GLWin.evdpy, attr.colormap);
}
void cXInterface::UpdateFPSDisplay(const char *text)
@@ -133,33 +133,33 @@ void cX11Window::CreateXWindow(void)
Atom wmProtocols[1];
// Setup window attributes
- GLWin.attr.colormap = XCreateColormap(GLWin.evdpy,
+ attr.colormap = XCreateColormap(GLWin.evdpy,
GLWin.parent, GLWin.vi->visual, AllocNone);
- GLWin.attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask;
- GLWin.attr.background_pixel = BlackPixel(GLWin.evdpy, GLWin.screen);
- GLWin.attr.border_pixel = 0;
+ attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask;
+ attr.background_pixel = BlackPixel(GLWin.evdpy, GLWin.screen);
+ attr.border_pixel = 0;
// Create the window
GLWin.win = XCreateWindow(GLWin.evdpy, GLWin.parent,
GLWin.x, GLWin.y, GLWin.width, GLWin.height, 0,
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
- CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr);
+ CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &attr);
wmProtocols[0] = XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", True);
XSetWMProtocols(GLWin.evdpy, GLWin.win, wmProtocols, 1);
XSetStandardProperties(GLWin.evdpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL);
XMapRaised(GLWin.evdpy, GLWin.win);
XSync(GLWin.evdpy, True);
- GLWin.xEventThread = std::thread(&cX11Window::XEventThread, this);
+ xEventThread = std::thread(&cX11Window::XEventThread, this);
}
void cX11Window::DestroyXWindow(void)
{
XUnmapWindow(GLWin.evdpy, GLWin.win);
GLWin.win = 0;
- if (GLWin.xEventThread.joinable())
- GLWin.xEventThread.join();
- XFreeColormap(GLWin.evdpy, GLWin.attr.colormap);
+ if (xEventThread.joinable())
+ xEventThread.join();
+ XFreeColormap(GLWin.evdpy, attr.colormap);
}
void cX11Window::XEventThread()
diff --git a/Source/Core/DolphinWX/Src/GLInterface/X11_Util.h b/Source/Core/DolphinWX/Src/GLInterface/X11_Util.h
index 321aa2a..e14f438 100644
--- a/Source/Core/DolphinWX/Src/GLInterface/X11_Util.h
+++ b/Source/Core/DolphinWX/Src/GLInterface/X11_Util.h
@@ -26,6 +26,10 @@ class cXInterface
{
private:
void XEventThread();
+
+ XSetWindowAttributes attr;
+ std::thread xEventThread;
+ Display *dpy;
public:
bool ServerConnect(void);
bool Initialize(void *config);
@@ -39,6 +43,9 @@ class cX11Window
{
private:
void XEventThread();
+
+ XSetWindowAttributes attr;
+ std::thread xEventThread;
public:
void CreateXWindow(void);
void DestroyXWindow(void);