Add back X11 support to EGL
Refactor the EGL backend to provide a platform separation here, which is better abstracted away than the old EGL/X11 implementation.
This commit is contained in:
parent
e39543b963
commit
271efb450c
|
@ -74,16 +74,22 @@ set(ANDROID_SRCS Android/ButtonManager.cpp
|
|||
|
||||
if(USE_EGL)
|
||||
set(SRCS ${SRCS} GLInterface/EGL.cpp)
|
||||
else()
|
||||
if(ANDROID)
|
||||
set(SRCS ${SRCS} GLInterface/EGLAndroid.cpp)
|
||||
elseif(USE_X11)
|
||||
set(SRCS ${SRCS} GLInterface/EGLX11.cpp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(SRCS ${SRCS} GLInterface/WGL.cpp)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(SRCS ${SRCS} GLInterface/AGL.cpp)
|
||||
else()
|
||||
elseif(USE_X11)
|
||||
set(SRCS ${SRCS} GLInterface/GLX.cpp
|
||||
GLInterface/X11_Util.cpp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(SRCS ${SRCS} GLInterface/GLInterface.cpp)
|
||||
|
||||
set(NOGUI_SRCS MainNoGUI.cpp)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/Host.h"
|
||||
#include "DolphinWX/GLInterface/EGL.h"
|
||||
#include "VideoBackends/OGL/GLInterfaceBase.h"
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
|
@ -90,7 +89,7 @@ bool cInterfaceEGL::Create(void *window_handle)
|
|||
const char *s;
|
||||
EGLint egl_major, egl_minor;
|
||||
|
||||
egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
egl_dpy = OpenDisplay();
|
||||
|
||||
if (!egl_dpy)
|
||||
{
|
||||
|
@ -154,14 +153,8 @@ bool cInterfaceEGL::Create(void *window_handle)
|
|||
else
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
EGLNativeWindowType native_window = (EGLNativeWindowType) window_handle;
|
||||
|
||||
EGLint format;
|
||||
eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &format);
|
||||
ANativeWindow_setBuffersGeometry(native_window, 0, 0, format);
|
||||
int none, width, height;
|
||||
Host_GetRenderWindowSize(none, none, width, height);
|
||||
GLInterface->SetBackBufferDimensions(width, height);
|
||||
EGLNativeWindowType host_window = (EGLNativeWindowType) window_handle;
|
||||
EGLNativeWindowType native_window = InitializePlatform(host_window, config);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
INFO_LOG(VIDEO, "EGL_VERSION = %s\n", s);
|
||||
|
@ -199,6 +192,7 @@ bool cInterfaceEGL::MakeCurrent()
|
|||
// Close backend
|
||||
void cInterfaceEGL::Shutdown()
|
||||
{
|
||||
ShutdownPlatform();
|
||||
if (egl_ctx && !eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx))
|
||||
NOTICE_LOG(VIDEO, "Could not release drawing context.");
|
||||
if (egl_ctx)
|
||||
|
|
|
@ -12,11 +12,15 @@
|
|||
|
||||
class cInterfaceEGL : public cInterfaceBase
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
void DetectMode();
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
|
||||
virtual EGLDisplay OpenDisplay() = 0;
|
||||
virtual EGLNativeWindowType InitializePlatform(EGLNativeWindowType host_window, EGLConfig config) = 0;
|
||||
virtual void ShutdownPlatform() = 0;
|
||||
public:
|
||||
void SwapInterval(int Interval);
|
||||
void Swap();
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2014 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/Host.h"
|
||||
#include "DolphinWX/GLInterface/EGLAndroid.h"
|
||||
|
||||
EGLDisplay cInterfaceEGLAndroid::OpenDisplay()
|
||||
{
|
||||
return eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
EGLNativeWindowType cInterfaceEGLAndroid::InitializePlatform(EGLNativeWindowType host_window, EGLConfig config)
|
||||
{
|
||||
EGLint format;
|
||||
eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &format);
|
||||
ANativeWindow_setBuffersGeometry(host_window, 0, 0, format);
|
||||
|
||||
int none, width, height;
|
||||
Host_GetRenderWindowSize(none, none, width, height);
|
||||
GLInterface->SetBackBufferDimensions(width, height);
|
||||
|
||||
return host_window;
|
||||
}
|
||||
|
||||
void cInterfaceEGLAndroid::ShutdownPlatform()
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2014 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DolphinWX/GLInterface/EGL.h"
|
||||
|
||||
class cInterfaceEGLAndroid : public cInterfaceEGL
|
||||
{
|
||||
protected:
|
||||
EGLDisplay OpenDisplay() override;
|
||||
EGLNativeWindowType InitializePlatform(EGLNativeWindowType host_window, EGLConfig config) override;
|
||||
void ShutdownPlatform() override;
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2014 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinWX/GLInterface/EGLX11.h"
|
||||
|
||||
EGLDisplay cInterfaceEGLX11::OpenDisplay()
|
||||
{
|
||||
dpy = XOpenDisplay(nullptr);
|
||||
XWindow.Initialize(dpy);
|
||||
return eglGetDisplay(dpy);
|
||||
}
|
||||
|
||||
EGLNativeWindowType cInterfaceEGLX11::InitializePlatform(EGLNativeWindowType host_window, EGLConfig config)
|
||||
{
|
||||
EGLint vid;
|
||||
eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid);
|
||||
|
||||
XVisualInfo visTemplate;
|
||||
visTemplate.visualid = vid;
|
||||
|
||||
XVisualInfo *vi;
|
||||
int nVisuals;
|
||||
vi = XGetVisualInfo(dpy, VisualIDMask, &visTemplate, &nVisuals);
|
||||
|
||||
return (EGLNativeWindowType) XWindow.CreateXWindow((Window) host_window, vi);
|
||||
}
|
||||
|
||||
void cInterfaceEGLX11::ShutdownPlatform()
|
||||
{
|
||||
XWindow.DestroyXWindow();
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2014 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "DolphinWX/GLInterface/EGL.h"
|
||||
#include "DolphinWX/GLInterface/X11_Util.h"
|
||||
|
||||
class cInterfaceEGLX11 : public cInterfaceEGL
|
||||
{
|
||||
private:
|
||||
cX11Window XWindow;
|
||||
Display *dpy;
|
||||
protected:
|
||||
EGLDisplay OpenDisplay() override;
|
||||
EGLNativeWindowType InitializePlatform(EGLNativeWindowType host_window, EGLConfig config) override;
|
||||
void ShutdownPlatform() override;
|
||||
};
|
|
@ -4,28 +4,36 @@
|
|||
|
||||
#include "VideoBackends/OGL/GLInterfaceBase.h"
|
||||
|
||||
#if USE_EGL
|
||||
#include "DolphinWX/GLInterface/EGL.h"
|
||||
#ifdef ANDROID
|
||||
#include "DolphinWX/GLInterface/EGLAndroid.h"
|
||||
#elif defined(__APPLE__)
|
||||
#include "DolphinWX/GLInterface/AGL.h"
|
||||
#elif defined(_WIN32)
|
||||
#include "DolphinWX/GLInterface/WGL.h"
|
||||
#elif HAVE_X11
|
||||
#if defined(USE_EGL) && USE_EGL
|
||||
#include "DolphinWX/GLInterface/EGLX11.h"
|
||||
#else
|
||||
#include "DolphinWX/GLInterface/GLX.h"
|
||||
#endif
|
||||
#else
|
||||
#error Platform doesnt have a GLInterface
|
||||
#endif
|
||||
|
||||
cInterfaceBase* HostGL_CreateGLInterface()
|
||||
{
|
||||
#if defined(USE_EGL) && USE_EGL
|
||||
return new cInterfaceEGL;
|
||||
#ifdef ANDROID
|
||||
return new cInterfaceEGLAndroid;
|
||||
#elif defined(__APPLE__)
|
||||
return new cInterfaceAGL;
|
||||
#elif defined(_WIN32)
|
||||
return new cInterfaceWGL;
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
#if defined(USE_EGL) && USE_EGL
|
||||
return new cInterfaceEGLX11;
|
||||
#else
|
||||
return new cInterfaceGLX;
|
||||
#endif
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue