GLInterface: Destroy GLWin
Everything is now safely tucked inside each individual GLInterface.
This commit is contained in:
parent
63f1a16969
commit
2d974b6086
|
@ -4,8 +4,10 @@
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "Common/FileUtil.h"
|
||||||
|
#include "Common/IniFile.h"
|
||||||
|
#include "Common/Thread.h"
|
||||||
#include "DolphinWX/Android/ButtonManager.h"
|
#include "DolphinWX/Android/ButtonManager.h"
|
||||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
|
||||||
|
|
||||||
namespace ButtonManager
|
namespace ButtonManager
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
@ -100,7 +100,6 @@
|
||||||
<ClCompile Include="WxUtils.cpp" />
|
<ClCompile Include="WxUtils.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="GLInterface\GLInterface.h" />
|
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
<ClInclude Include="AboutDolphin.h" />
|
<ClInclude Include="AboutDolphin.h" />
|
||||||
<ClInclude Include="ARCodeAddEdit.h" />
|
<ClInclude Include="ARCodeAddEdit.h" />
|
||||||
|
|
|
@ -282,7 +282,6 @@
|
||||||
<ClInclude Include="WiimoteConfigDiag.h">
|
<ClInclude Include="WiimoteConfigDiag.h">
|
||||||
<Filter>GUI</Filter>
|
<Filter>GUI</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="GLInterface\GLInterface.h" />
|
|
||||||
<ClInclude Include="SoftwareVideoConfigDialog.h">
|
<ClInclude Include="SoftwareVideoConfigDialog.h">
|
||||||
<Filter>GUI\Video</Filter>
|
<Filter>GUI\Video</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -4,14 +4,15 @@
|
||||||
|
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
|
|
||||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
#include "DolphinWX/GLInterface/AGL.h"
|
||||||
|
|
||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
#include "VideoCommon/VertexShaderManager.h"
|
#include "VideoCommon/VertexShaderManager.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
void cInterfaceAGL::Swap()
|
void cInterfaceAGL::Swap()
|
||||||
{
|
{
|
||||||
[GLWin.cocoaCtx flushBuffer];
|
[cocoaCtx flushBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create rendering window.
|
// Create rendering window.
|
||||||
|
@ -19,13 +20,13 @@ void cInterfaceAGL::Swap()
|
||||||
bool cInterfaceAGL::Create(void *window_handle)
|
bool cInterfaceAGL::Create(void *window_handle)
|
||||||
{
|
{
|
||||||
// FIXME: Get rid of the explicit use of wxPanel here. This shouldn't be necessary.
|
// FIXME: Get rid of the explicit use of wxPanel here. This shouldn't be necessary.
|
||||||
GLWin.cocoaWin = reinterpret_cast<NSView*>(((wxPanel*)window_handle)->GetHandle());
|
cocoaWin = reinterpret_cast<NSView*>(((wxPanel*)window_handle)->GetHandle());
|
||||||
NSSize size = [GLWin.cocoaWin frame].size;
|
NSSize size = [cocoaWin frame].size;
|
||||||
|
|
||||||
// Enable high-resolution display support.
|
// 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];
|
float scale = [window backingScaleFactor];
|
||||||
size.width *= scale;
|
size.width *= scale;
|
||||||
|
@ -43,21 +44,21 @@ bool cInterfaceAGL::Create(void *window_handle)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLWin.cocoaCtx = [[NSOpenGLContext alloc]
|
cocoaCtx = [[NSOpenGLContext alloc]
|
||||||
initWithFormat: fmt shareContext: nil];
|
initWithFormat: fmt shareContext: nil];
|
||||||
[fmt release];
|
[fmt release];
|
||||||
if (GLWin.cocoaCtx == nil) {
|
if (cocoaCtx == nil) {
|
||||||
ERROR_LOG(VIDEO, "failed to create context");
|
ERROR_LOG(VIDEO, "failed to create context");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GLWin.cocoaWin == nil) {
|
if (cocoaWin == nil) {
|
||||||
ERROR_LOG(VIDEO, "failed to create window");
|
ERROR_LOG(VIDEO, "failed to create window");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[window makeFirstResponder:GLWin.cocoaWin];
|
[window makeFirstResponder:cocoaWin];
|
||||||
[GLWin.cocoaCtx setView: GLWin.cocoaWin];
|
[cocoaCtx setView: cocoaWin];
|
||||||
[window makeKeyAndOrderFront: nil];
|
[window makeKeyAndOrderFront: nil];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -65,7 +66,7 @@ bool cInterfaceAGL::Create(void *window_handle)
|
||||||
|
|
||||||
bool cInterfaceAGL::MakeCurrent()
|
bool cInterfaceAGL::MakeCurrent()
|
||||||
{
|
{
|
||||||
[GLWin.cocoaCtx makeCurrentContext];
|
[cocoaCtx makeCurrentContext];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,15 +80,15 @@ bool cInterfaceAGL::ClearCurrent()
|
||||||
// Close backend
|
// Close backend
|
||||||
void cInterfaceAGL::Shutdown()
|
void cInterfaceAGL::Shutdown()
|
||||||
{
|
{
|
||||||
[GLWin.cocoaCtx clearDrawable];
|
[cocoaCtx clearDrawable];
|
||||||
[GLWin.cocoaCtx release];
|
[cocoaCtx release];
|
||||||
GLWin.cocoaCtx = nil;
|
cocoaCtx = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cInterfaceAGL::Update()
|
void cInterfaceAGL::Update()
|
||||||
{
|
{
|
||||||
NSWindow *window = [GLWin.cocoaWin window];
|
NSWindow *window = [cocoaWin window];
|
||||||
NSSize size = [GLWin.cocoaWin frame].size;
|
NSSize size = [cocoaWin frame].size;
|
||||||
|
|
||||||
float scale = [window backingScaleFactor];
|
float scale = [window backingScaleFactor];
|
||||||
size.width *= scale;
|
size.width *= scale;
|
||||||
|
@ -100,11 +101,11 @@ void cInterfaceAGL::Update()
|
||||||
s_backbuffer_width = size.width;
|
s_backbuffer_width = size.width;
|
||||||
s_backbuffer_height = size.height;
|
s_backbuffer_height = size.height;
|
||||||
|
|
||||||
[GLWin.cocoaCtx update];
|
[cocoaCtx update];
|
||||||
}
|
}
|
||||||
|
|
||||||
void cInterfaceAGL::SwapInterval(int interval)
|
void cInterfaceAGL::SwapInterval(int interval)
|
||||||
{
|
{
|
||||||
[GLWin.cocoaCtx setValues:(GLint *)&interval forParameter:NSOpenGLCPSwapInterval];
|
[cocoaCtx setValues:(GLint *)&interval forParameter:NSOpenGLCPSwapInterval];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
class cInterfaceAGL : public cInterfaceBase
|
class cInterfaceAGL : public cInterfaceBase
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
NSView *cocoaWin;
|
||||||
|
NSOpenGLContext *cocoaCtx;
|
||||||
public:
|
public:
|
||||||
void Swap();
|
void Swap();
|
||||||
bool Create(void *window_handle);
|
bool Create(void *window_handle);
|
||||||
|
|
|
@ -3,17 +3,18 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
#include "DolphinWX/GLInterface/EGL.h"
|
||||||
|
#include "VideoBackends/OGL/GLInterfaceBase.h"
|
||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
|
|
||||||
// Show the current FPS
|
// Show the current FPS
|
||||||
void cInterfaceEGL::Swap()
|
void cInterfaceEGL::Swap()
|
||||||
{
|
{
|
||||||
eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
|
eglSwapBuffers(egl_dpy, egl_surf);
|
||||||
}
|
}
|
||||||
void cInterfaceEGL::SwapInterval(int Interval)
|
void cInterfaceEGL::SwapInterval(int Interval)
|
||||||
{
|
{
|
||||||
eglSwapInterval(GLWin.egl_dpy, Interval);
|
eglSwapInterval(egl_dpy, Interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* cInterfaceEGL::GetFuncAddress(const std::string& name)
|
void* cInterfaceEGL::GetFuncAddress(const std::string& name)
|
||||||
|
@ -39,7 +40,7 @@ void cInterfaceEGL::DetectMode()
|
||||||
EGL_NONE };
|
EGL_NONE };
|
||||||
|
|
||||||
// Get how many configs there are
|
// Get how many configs there are
|
||||||
if (!eglChooseConfig( GLWin.egl_dpy, attribs, nullptr, 0, &num_configs))
|
if (!eglChooseConfig( egl_dpy, attribs, nullptr, 0, &num_configs))
|
||||||
{
|
{
|
||||||
INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
|
INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
|
@ -48,7 +49,7 @@ void cInterfaceEGL::DetectMode()
|
||||||
config = new EGLConfig[num_configs];
|
config = new EGLConfig[num_configs];
|
||||||
|
|
||||||
// Get all the configurations
|
// Get all the configurations
|
||||||
if (!eglChooseConfig(GLWin.egl_dpy, attribs, config, num_configs, &num_configs))
|
if (!eglChooseConfig(egl_dpy, attribs, config, num_configs, &num_configs))
|
||||||
{
|
{
|
||||||
INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
|
INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
|
@ -58,7 +59,7 @@ void cInterfaceEGL::DetectMode()
|
||||||
{
|
{
|
||||||
EGLint attribVal;
|
EGLint attribVal;
|
||||||
bool ret;
|
bool ret;
|
||||||
ret = eglGetConfigAttrib(GLWin.egl_dpy, config[i], EGL_RENDERABLE_TYPE, &attribVal);
|
ret = eglGetConfigAttrib(egl_dpy, config[i], EGL_RENDERABLE_TYPE, &attribVal);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
if (attribVal & EGL_OPENGL_BIT)
|
if (attribVal & EGL_OPENGL_BIT)
|
||||||
|
@ -89,15 +90,15 @@ bool cInterfaceEGL::Create(void *window_handle)
|
||||||
const char *s;
|
const char *s;
|
||||||
EGLint egl_major, egl_minor;
|
EGLint egl_major, egl_minor;
|
||||||
|
|
||||||
GLWin.egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
|
||||||
if (!GLWin.egl_dpy)
|
if (!egl_dpy)
|
||||||
{
|
{
|
||||||
INFO_LOG(VIDEO, "Error: eglGetDisplay() failed\n");
|
INFO_LOG(VIDEO, "Error: eglGetDisplay() failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor))
|
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor))
|
||||||
{
|
{
|
||||||
INFO_LOG(VIDEO, "Error: eglInitialize() failed\n");
|
INFO_LOG(VIDEO, "Error: eglInitialize() failed\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -142,7 +143,7 @@ bool cInterfaceEGL::Create(void *window_handle)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglChooseConfig( GLWin.egl_dpy, attribs, &config, 1, &num_configs))
|
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs))
|
||||||
{
|
{
|
||||||
INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
|
INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -153,38 +154,36 @@ bool cInterfaceEGL::Create(void *window_handle)
|
||||||
else
|
else
|
||||||
eglBindAPI(EGL_OPENGL_ES_API);
|
eglBindAPI(EGL_OPENGL_ES_API);
|
||||||
|
|
||||||
EGLNativeWindowType native_window = window_handle;
|
EGLNativeWindowType native_window = (EGLNativeWindowType) window_handle;
|
||||||
|
|
||||||
EGLint format;
|
EGLint format;
|
||||||
eglGetConfigAttrib(GLWin.egl_dpy, config, EGL_NATIVE_VISUAL_ID, &format);
|
eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &format);
|
||||||
ANativeWindow_setBuffersGeometry(native_window, 0, 0, format);
|
ANativeWindow_setBuffersGeometry(native_window, 0, 0, format);
|
||||||
int none, width, height;
|
int none, width, height;
|
||||||
Host_GetRenderWindowSize(none, none, width, height);
|
Host_GetRenderWindowSize(none, none, width, height);
|
||||||
GLWin.width = width;
|
|
||||||
GLWin.height = height;
|
|
||||||
GLInterface->SetBackBufferDimensions(width, height);
|
GLInterface->SetBackBufferDimensions(width, height);
|
||||||
|
|
||||||
s = eglQueryString(GLWin.egl_dpy, EGL_VERSION);
|
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||||
INFO_LOG(VIDEO, "EGL_VERSION = %s\n", s);
|
INFO_LOG(VIDEO, "EGL_VERSION = %s\n", s);
|
||||||
|
|
||||||
s = eglQueryString(GLWin.egl_dpy, EGL_VENDOR);
|
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||||
INFO_LOG(VIDEO, "EGL_VENDOR = %s\n", s);
|
INFO_LOG(VIDEO, "EGL_VENDOR = %s\n", s);
|
||||||
|
|
||||||
s = eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS);
|
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||||
INFO_LOG(VIDEO, "EGL_EXTENSIONS = %s\n", s);
|
INFO_LOG(VIDEO, "EGL_EXTENSIONS = %s\n", s);
|
||||||
|
|
||||||
s = eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS);
|
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||||
INFO_LOG(VIDEO, "EGL_CLIENT_APIS = %s\n", s);
|
INFO_LOG(VIDEO, "EGL_CLIENT_APIS = %s\n", s);
|
||||||
|
|
||||||
GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
|
egl_ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
|
||||||
if (!GLWin.egl_ctx)
|
if (!egl_ctx)
|
||||||
{
|
{
|
||||||
INFO_LOG(VIDEO, "Error: eglCreateContext failed\n");
|
INFO_LOG(VIDEO, "Error: eglCreateContext failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config, native_window, nullptr);
|
egl_surf = eglCreateWindowSurface(egl_dpy, config, native_window, nullptr);
|
||||||
if (!GLWin.egl_surf)
|
if (!egl_surf)
|
||||||
{
|
{
|
||||||
INFO_LOG(VIDEO, "Error: eglCreateWindowSurface failed\n");
|
INFO_LOG(VIDEO, "Error: eglCreateWindowSurface failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -195,22 +194,22 @@ bool cInterfaceEGL::Create(void *window_handle)
|
||||||
|
|
||||||
bool cInterfaceEGL::MakeCurrent()
|
bool cInterfaceEGL::MakeCurrent()
|
||||||
{
|
{
|
||||||
return eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx);
|
return eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx);
|
||||||
}
|
}
|
||||||
// Close backend
|
// Close backend
|
||||||
void cInterfaceEGL::Shutdown()
|
void cInterfaceEGL::Shutdown()
|
||||||
{
|
{
|
||||||
if (GLWin.egl_ctx && !eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx))
|
if (egl_ctx && !eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx))
|
||||||
NOTICE_LOG(VIDEO, "Could not release drawing context.");
|
NOTICE_LOG(VIDEO, "Could not release drawing context.");
|
||||||
if (GLWin.egl_ctx)
|
if (egl_ctx)
|
||||||
{
|
{
|
||||||
eglMakeCurrent(GLWin.egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
if (!eglDestroyContext(GLWin.egl_dpy, GLWin.egl_ctx))
|
if (!eglDestroyContext(egl_dpy, egl_ctx))
|
||||||
NOTICE_LOG(VIDEO, "Could not destroy drawing context.");
|
NOTICE_LOG(VIDEO, "Could not destroy drawing context.");
|
||||||
if (!eglDestroySurface(GLWin.egl_dpy, GLWin.egl_surf))
|
if (!eglDestroySurface(egl_dpy, egl_surf))
|
||||||
NOTICE_LOG(VIDEO, "Could not destroy window surface.");
|
NOTICE_LOG(VIDEO, "Could not destroy window surface.");
|
||||||
if (!eglTerminate(GLWin.egl_dpy))
|
if (!eglTerminate(egl_dpy))
|
||||||
NOTICE_LOG(VIDEO, "Could not destroy display connection.");
|
NOTICE_LOG(VIDEO, "Could not destroy display connection.");
|
||||||
GLWin.egl_ctx = nullptr;
|
egl_ctx = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,9 @@ class cInterfaceEGL : public cInterfaceBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
void DetectMode();
|
void DetectMode();
|
||||||
|
EGLSurface egl_surf;
|
||||||
|
EGLContext egl_ctx;
|
||||||
|
EGLDisplay egl_dpy;
|
||||||
public:
|
public:
|
||||||
void SwapInterval(int Interval);
|
void SwapInterval(int Interval);
|
||||||
void Swap();
|
void Swap();
|
||||||
|
|
|
@ -2,10 +2,19 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
|
||||||
#include "VideoBackends/OGL/GLInterfaceBase.h"
|
#include "VideoBackends/OGL/GLInterfaceBase.h"
|
||||||
|
|
||||||
GLWindow GLWin;
|
#if USE_EGL
|
||||||
|
#include "DolphinWX/GLInterface/EGL.h"
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include "DolphinWX/GLInterface/AGL.h"
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
#include "DolphinWX/GLInterface/WGL.h"
|
||||||
|
#elif HAVE_X11
|
||||||
|
#include "DolphinWX/GLInterface/GLX.h"
|
||||||
|
#else
|
||||||
|
#error Platform doesnt have a GLInterface
|
||||||
|
#endif
|
||||||
|
|
||||||
cInterfaceBase* HostGL_CreateGLInterface()
|
cInterfaceBase* HostGL_CreateGLInterface()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
// Copyright 2013 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Common/Thread.h"
|
|
||||||
|
|
||||||
#if USE_EGL
|
|
||||||
#include "DolphinWX/GLInterface/EGL.h"
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include "DolphinWX/GLInterface/AGL.h"
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
#include "DolphinWX/GLInterface/WGL.h"
|
|
||||||
#elif HAVE_X11
|
|
||||||
#include "DolphinWX/GLInterface/GLX.h"
|
|
||||||
#include <GL/glx.h>
|
|
||||||
#else
|
|
||||||
#error Platform doesnt have a GLInterface
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
#if USE_EGL
|
|
||||||
EGLSurface egl_surf;
|
|
||||||
EGLContext egl_ctx;
|
|
||||||
EGLDisplay egl_dpy;
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
NSView *cocoaWin;
|
|
||||||
NSOpenGLContext *cocoaCtx;
|
|
||||||
#elif HAVE_X11
|
|
||||||
GLXContext ctx;
|
|
||||||
int screen;
|
|
||||||
Window win;
|
|
||||||
Window parent;
|
|
||||||
Display *dpy;
|
|
||||||
XVisualInfo *vi;
|
|
||||||
XSetWindowAttributes attr;
|
|
||||||
std::thread xEventThread;
|
|
||||||
#endif
|
|
||||||
} GLWindow;
|
|
||||||
|
|
||||||
extern GLWindow GLWin;
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
#include "DolphinWX/GLInterface/GLX.h"
|
||||||
|
|
||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
@ -26,7 +26,7 @@ void* cInterfaceGLX::GetFuncAddress(const std::string& name)
|
||||||
|
|
||||||
void cInterfaceGLX::Swap()
|
void cInterfaceGLX::Swap()
|
||||||
{
|
{
|
||||||
glXSwapBuffers(GLWin.dpy, GLWin.win);
|
glXSwapBuffers(dpy, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create rendering window.
|
// Create rendering window.
|
||||||
|
@ -58,26 +58,25 @@ bool cInterfaceGLX::Create(void *window_handle)
|
||||||
GLX_DOUBLEBUFFER,
|
GLX_DOUBLEBUFFER,
|
||||||
None };
|
None };
|
||||||
|
|
||||||
GLWin.dpy = XOpenDisplay(nullptr);
|
dpy = XOpenDisplay(nullptr);
|
||||||
GLWin.parent = (Window)window_handle;
|
int screen = DefaultScreen(dpy);
|
||||||
GLWin.screen = DefaultScreen(GLWin.dpy);
|
|
||||||
|
|
||||||
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
|
glXQueryVersion(dpy, &glxMajorVersion, &glxMinorVersion);
|
||||||
NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion);
|
NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion);
|
||||||
|
|
||||||
// Get an appropriate visual
|
// Get an appropriate visual
|
||||||
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDbl);
|
vi = glXChooseVisual(dpy, screen, attrListDbl);
|
||||||
if (GLWin.vi == nullptr)
|
if (vi == nullptr)
|
||||||
{
|
{
|
||||||
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl);
|
vi = glXChooseVisual(dpy, screen, attrListSgl);
|
||||||
if (GLWin.vi != nullptr)
|
if (vi != nullptr)
|
||||||
{
|
{
|
||||||
ERROR_LOG(VIDEO, "Only single buffered visual!");
|
ERROR_LOG(VIDEO, "Only single buffered visual!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDefault);
|
vi = glXChooseVisual(dpy, screen, attrListDefault);
|
||||||
if (GLWin.vi == nullptr)
|
if (vi == nullptr)
|
||||||
{
|
{
|
||||||
ERROR_LOG(VIDEO, "Could not choose visual (glXChooseVisual)");
|
ERROR_LOG(VIDEO, "Could not choose visual (glXChooseVisual)");
|
||||||
return false;
|
return false;
|
||||||
|
@ -88,20 +87,23 @@ bool cInterfaceGLX::Create(void *window_handle)
|
||||||
NOTICE_LOG(VIDEO, "Got double buffered visual!");
|
NOTICE_LOG(VIDEO, "Got double buffered visual!");
|
||||||
|
|
||||||
// Create a GLX context.
|
// Create a GLX context.
|
||||||
GLWin.ctx = glXCreateContext(GLWin.dpy, GLWin.vi, nullptr, GL_TRUE);
|
ctx = glXCreateContext(dpy, vi, nullptr, GL_TRUE);
|
||||||
if (!GLWin.ctx)
|
if (!ctx)
|
||||||
{
|
{
|
||||||
PanicAlert("Unable to create GLX context.");
|
PanicAlert("Unable to create GLX context.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
XWindow.CreateXWindow();
|
XWindow.Initialize(dpy);
|
||||||
|
|
||||||
|
Window parent = (Window)window_handle;
|
||||||
|
win = XWindow.CreateXWindow(parent, vi);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cInterfaceGLX::MakeCurrent()
|
bool cInterfaceGLX::MakeCurrent()
|
||||||
{
|
{
|
||||||
bool success = glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx);
|
bool success = glXMakeCurrent(dpy, win, ctx);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
// load this function based on the current bound context
|
// load this function based on the current bound context
|
||||||
|
@ -112,7 +114,7 @@ bool cInterfaceGLX::MakeCurrent()
|
||||||
|
|
||||||
bool cInterfaceGLX::ClearCurrent()
|
bool cInterfaceGLX::ClearCurrent()
|
||||||
{
|
{
|
||||||
return glXMakeCurrent(GLWin.dpy, None, nullptr);
|
return glXMakeCurrent(dpy, None, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,11 +122,11 @@ bool cInterfaceGLX::ClearCurrent()
|
||||||
void cInterfaceGLX::Shutdown()
|
void cInterfaceGLX::Shutdown()
|
||||||
{
|
{
|
||||||
XWindow.DestroyXWindow();
|
XWindow.DestroyXWindow();
|
||||||
if (GLWin.ctx)
|
if (ctx)
|
||||||
{
|
{
|
||||||
glXDestroyContext(GLWin.dpy, GLWin.ctx);
|
glXDestroyContext(dpy, ctx);
|
||||||
XCloseDisplay(GLWin.dpy);
|
XCloseDisplay(dpy);
|
||||||
GLWin.ctx = nullptr;
|
ctx = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <GL/glx.h>
|
||||||
|
|
||||||
#include "DolphinWX/GLInterface/X11_Util.h"
|
#include "DolphinWX/GLInterface/X11_Util.h"
|
||||||
#include "VideoBackends/OGL/GLInterfaceBase.h"
|
#include "VideoBackends/OGL/GLInterfaceBase.h"
|
||||||
|
@ -13,6 +14,10 @@ class cInterfaceGLX : public cInterfaceBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
cX11Window XWindow;
|
cX11Window XWindow;
|
||||||
|
Display *dpy;
|
||||||
|
Window win;
|
||||||
|
GLXContext ctx;
|
||||||
|
XVisualInfo *vi;
|
||||||
public:
|
public:
|
||||||
friend class cX11Window;
|
friend class cX11Window;
|
||||||
void SwapInterval(int Interval) override;
|
void SwapInterval(int Interval) override;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
|
|
||||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
#include "DolphinWX/GLInterface/WGL.h"
|
||||||
|
|
||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
#include "VideoCommon/VertexShaderManager.h"
|
#include "VideoCommon/VertexShaderManager.h"
|
||||||
|
|
|
@ -2,50 +2,61 @@
|
||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "Common/Thread.h"
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
#include "DolphinWX/GLInterface/X11_Util.h"
|
||||||
|
#include "VideoBackends/OGL/GLInterfaceBase.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
void cX11Window::CreateXWindow(void)
|
void cX11Window::Initialize(Display *_dpy)
|
||||||
{
|
{
|
||||||
|
dpy = _dpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
Window cX11Window::CreateXWindow(Window parent, XVisualInfo *vi)
|
||||||
|
{
|
||||||
|
XSetWindowAttributes attr;
|
||||||
|
|
||||||
|
colormap = XCreateColormap(dpy, parent, vi->visual, AllocNone);
|
||||||
|
|
||||||
// Setup window attributes
|
// Setup window attributes
|
||||||
GLWin.attr.colormap = XCreateColormap(GLWin.dpy,
|
attr.colormap = colormap;
|
||||||
GLWin.parent, GLWin.vi->visual, AllocNone);
|
attr.background_pixel = BlackPixel(dpy, 0);
|
||||||
GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen);
|
attr.border_pixel = 0;
|
||||||
GLWin.attr.border_pixel = 0;
|
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
GLWin.win = XCreateWindow(GLWin.dpy, GLWin.parent,
|
win = XCreateWindow(dpy, parent,
|
||||||
0, 0, 1, 1, 0,
|
0, 0, 1, 1, 0,
|
||||||
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
|
vi->depth, InputOutput, vi->visual,
|
||||||
CWBorderPixel | CWBackPixel | CWColormap, &GLWin.attr);
|
CWBorderPixel | CWBackPixel | CWColormap, &attr);
|
||||||
XSelectInput(GLWin.dpy, GLWin.parent, StructureNotifyMask);
|
XSelectInput(dpy, parent, StructureNotifyMask);
|
||||||
XMapWindow(GLWin.dpy, GLWin.win);
|
XMapWindow(dpy, win);
|
||||||
XSync(GLWin.dpy, True);
|
XSync(dpy, True);
|
||||||
|
|
||||||
GLWin.xEventThread = std::thread(&cX11Window::XEventThread, this);
|
xEventThread = std::thread(&cX11Window::XEventThread, this);
|
||||||
|
|
||||||
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cX11Window::DestroyXWindow(void)
|
void cX11Window::DestroyXWindow(void)
|
||||||
{
|
{
|
||||||
XUnmapWindow(GLWin.dpy, GLWin.win);
|
XUnmapWindow(dpy, win);
|
||||||
GLWin.win = 0;
|
if (xEventThread.joinable())
|
||||||
if (GLWin.xEventThread.joinable())
|
xEventThread.join();
|
||||||
GLWin.xEventThread.join();
|
XFreeColormap(dpy, colormap);
|
||||||
XFreeColormap(GLWin.dpy, GLWin.attr.colormap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cX11Window::XEventThread()
|
void cX11Window::XEventThread()
|
||||||
{
|
{
|
||||||
while (GLWin.win)
|
while (win)
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
for (int num_events = XPending(GLWin.dpy); num_events > 0; num_events--)
|
for (int num_events = XPending(dpy); num_events > 0; num_events--)
|
||||||
{
|
{
|
||||||
XNextEvent(GLWin.dpy, &event);
|
XNextEvent(dpy, &event);
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
XResizeWindow(GLWin.dpy, GLWin.win, event.xconfigure.width, event.xconfigure.height);
|
XResizeWindow(dpy, win, event.xconfigure.width, event.xconfigure.height);
|
||||||
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
@ -13,7 +14,13 @@ class cX11Window
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
void XEventThread();
|
void XEventThread();
|
||||||
|
std::thread xEventThread;
|
||||||
|
Colormap colormap;
|
||||||
public:
|
public:
|
||||||
void CreateXWindow(void);
|
void Initialize(Display *dpy);
|
||||||
|
Window CreateXWindow(Window parent, XVisualInfo *vi);
|
||||||
void DestroyXWindow(void);
|
void DestroyXWindow(void);
|
||||||
|
|
||||||
|
Display *dpy;
|
||||||
|
Window win;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,10 +5,6 @@
|
||||||
#include "Common/Thread.h"
|
#include "Common/Thread.h"
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
|
|
||||||
#if USE_EGL
|
|
||||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CIFACE_USE_XINPUT
|
#ifdef CIFACE_USE_XINPUT
|
||||||
#include "InputCommon/ControllerInterface/XInput/XInput.h"
|
#include "InputCommon/ControllerInterface/XInput/XInput.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue