Merge Platform.h into GLInterface.h
This commit is contained in:
parent
75020b9b51
commit
4b3c338930
|
@ -5,37 +5,96 @@
|
||||||
#ifndef _GLINTERFACE_H_
|
#ifndef _GLINTERFACE_H_
|
||||||
#define _GLINTERFACE_H_
|
#define _GLINTERFACE_H_
|
||||||
|
|
||||||
#if USE_EGL
|
|
||||||
#include "GLInterface/Platform.h"
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#if defined(USE_EGL) && USE_EGL
|
|
||||||
|
#if USE_EGL
|
||||||
|
// Currently Wayland/EGL and X11/EGL platforms are supported.
|
||||||
|
// The platform may be spelected at run time by setting the
|
||||||
|
// environment variable DOLPHIN_EGL_PLATFORM to "wayland" or "x11".
|
||||||
|
|
||||||
|
enum egl_platform {
|
||||||
|
EGL_PLATFORM_NONE,
|
||||||
|
EGL_PLATFORM_WAYLAND,
|
||||||
|
EGL_PLATFORM_X11,
|
||||||
|
EGL_PLATFORM_ANDROID
|
||||||
|
};
|
||||||
|
|
||||||
|
#if HAVE_X11
|
||||||
|
#include "GLInterface/X11_Util.h"
|
||||||
|
#endif
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
#include "GLInterface/Wayland_Util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "GLInterface/EGL.h"
|
#include "GLInterface/EGL.h"
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include "GLInterface/AGL.h"
|
#include "GLInterface/AGL.h"
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#include "GLInterface/WGL.h"
|
#include "GLInterface/WGL.h"
|
||||||
#elif defined(HAVE_X11) && HAVE_X11
|
#elif HAVE_X11
|
||||||
#include "GLInterface/GLX.h"
|
#include "GLInterface/GLX.h"
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#else
|
#else
|
||||||
#error Platform doesnt have a GLInterface
|
#error Platform doesnt have a GLInterface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
struct geometry {
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct xkb {
|
||||||
|
struct xkb_context *context;
|
||||||
|
struct xkb_keymap *keymap;
|
||||||
|
struct xkb_state *state;
|
||||||
|
xkb_mod_mask_t control_mask;
|
||||||
|
xkb_mod_mask_t alt_mask;
|
||||||
|
xkb_mod_mask_t shift_mask;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#if defined(USE_EGL) && USE_EGL // This is currently a X11/EGL implementation for desktop
|
#if HAVE_WAYLAND
|
||||||
int screen;
|
struct wl_display *wl_display;
|
||||||
|
struct wl_registry *wl_registry;
|
||||||
|
struct wl_compositor *wl_compositor;
|
||||||
|
struct wl_shell *wl_shell;
|
||||||
|
struct wl_seat *wl_seat;
|
||||||
|
struct {
|
||||||
|
struct wl_pointer *wl_pointer;
|
||||||
|
uint32_t serial;
|
||||||
|
} pointer;
|
||||||
|
struct {
|
||||||
|
struct wl_keyboard *wl_keyboard;
|
||||||
|
struct xkb xkb;
|
||||||
|
uint32_t modifiers;
|
||||||
|
} keyboard;
|
||||||
|
struct wl_shm *wl_shm;
|
||||||
|
struct wl_cursor_theme *wl_cursor_theme;
|
||||||
|
struct wl_cursor *wl_cursor;
|
||||||
|
struct wl_surface *wl_cursor_surface;
|
||||||
|
struct geometry geometry, window_size;
|
||||||
|
struct wl_egl_window *wl_egl_native;
|
||||||
|
struct wl_surface *wl_surface;
|
||||||
|
struct wl_shell_surface *wl_shell_surface;
|
||||||
|
bool fullscreen, running;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if USE_EGL
|
||||||
EGLSurface egl_surf;
|
EGLSurface egl_surf;
|
||||||
EGLContext egl_ctx;
|
EGLContext egl_ctx;
|
||||||
EGLDisplay egl_dpy;
|
EGLDisplay egl_dpy;
|
||||||
int x, y;
|
enum egl_platform platform;
|
||||||
unsigned int width, height;
|
EGLNativeWindowType native_window;
|
||||||
#elif defined(__APPLE__)
|
#elif HAVE_X11
|
||||||
|
GLXContext ctx;
|
||||||
|
#endif
|
||||||
|
#if defined(__APPLE__)
|
||||||
NSView *cocoaWin;
|
NSView *cocoaWin;
|
||||||
NSOpenGLContext *cocoaCtx;
|
NSOpenGLContext *cocoaCtx;
|
||||||
#elif defined(HAVE_X11) && HAVE_X11
|
#elif HAVE_X11
|
||||||
int screen;
|
int screen;
|
||||||
Window win;
|
Window win;
|
||||||
Window parent;
|
Window parent;
|
||||||
|
@ -43,16 +102,14 @@ typedef struct {
|
||||||
// evdpy is to be used by XEventThread only
|
// evdpy is to be used by XEventThread only
|
||||||
Display *dpy, *evdpy;
|
Display *dpy, *evdpy;
|
||||||
XVisualInfo *vi;
|
XVisualInfo *vi;
|
||||||
GLXContext ctx;
|
|
||||||
XSetWindowAttributes attr;
|
XSetWindowAttributes attr;
|
||||||
std::thread xEventThread;
|
std::thread xEventThread;
|
||||||
|
#endif
|
||||||
int x, y;
|
int x, y;
|
||||||
unsigned int width, height;
|
unsigned int width, height;
|
||||||
#endif
|
|
||||||
} GLWindow;
|
} GLWindow;
|
||||||
|
|
||||||
extern cInterfaceBase *GLInterface;
|
extern cInterfaceBase *GLInterface;
|
||||||
extern GLWindow GLWin;
|
extern GLWindow GLWin;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
|
@ -19,8 +19,29 @@
|
||||||
|
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include "InterfaceBase.h"
|
#include "InterfaceBase.h"
|
||||||
|
#include "ConfigManager.h"
|
||||||
|
|
||||||
class cPlatform;
|
|
||||||
|
class cPlatform
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
#if HAVE_X11
|
||||||
|
cXInterface XInterface;
|
||||||
|
#endif
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
cWaylandInterface WaylandInterface;
|
||||||
|
#endif
|
||||||
|
public:
|
||||||
|
enum egl_platform platform;
|
||||||
|
bool SelectDisplay(void);
|
||||||
|
bool Init(EGLConfig config);
|
||||||
|
EGLDisplay EGLGetDisplay(void);
|
||||||
|
EGLNativeWindowType CreateWindow(void);
|
||||||
|
void DestroyWindow(void);
|
||||||
|
void UpdateFPSDisplay(const char *text);
|
||||||
|
void ToggleFullscreen(bool fullscreen);
|
||||||
|
void SwapBuffers();
|
||||||
|
};
|
||||||
|
|
||||||
class cInterfaceEGL : public cInterfaceBase
|
class cInterfaceEGL : public cInterfaceBase
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include "Host.h"
|
#include "Host.h"
|
||||||
#include "Platform.h"
|
#include "GLInterface.h"
|
||||||
|
|
||||||
bool cPlatform::SelectDisplay(void)
|
bool cPlatform::SelectDisplay(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,162 +0,0 @@
|
||||||
// Copyright (C) 2013 Scott Moreau <oreaus@gmail.com>
|
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, version 2.0.
|
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License 2.0 for more details.
|
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
|
||||||
// If not, see http://www.gnu.org/licenses/
|
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
|
||||||
// http://code.google.com/p/dolphin-emu/
|
|
||||||
#ifndef _EGLPLATFORM_H_
|
|
||||||
#define _EGLPLATFORM_H_
|
|
||||||
|
|
||||||
#include "Thread.h"
|
|
||||||
#include "ConfigManager.h"
|
|
||||||
|
|
||||||
#if USE_EGL
|
|
||||||
// We must include wayland-egl.h before egl.h so our
|
|
||||||
// native types are defined as wayland native types
|
|
||||||
#if HAVE_WAYLAND && !HAVE_X11
|
|
||||||
#include <wayland-egl.h>
|
|
||||||
#endif
|
|
||||||
#include <EGL/egl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_X11
|
|
||||||
#include "X11_Util.h"
|
|
||||||
#endif
|
|
||||||
#if HAVE_WAYLAND
|
|
||||||
#include "Wayland_Util.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if USE_EGL
|
|
||||||
// There may be multiple EGL platforms
|
|
||||||
enum egl_platform {
|
|
||||||
EGL_PLATFORM_NONE,
|
|
||||||
EGL_PLATFORM_WAYLAND,
|
|
||||||
EGL_PLATFORM_X11,
|
|
||||||
EGL_PLATFORM_ANDROID
|
|
||||||
};
|
|
||||||
|
|
||||||
class cPlatform
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
#if HAVE_X11
|
|
||||||
cXInterface XInterface;
|
|
||||||
#endif
|
|
||||||
#if HAVE_WAYLAND
|
|
||||||
cWaylandInterface WaylandInterface;
|
|
||||||
#endif
|
|
||||||
public:
|
|
||||||
enum egl_platform platform;
|
|
||||||
bool SelectDisplay(void);
|
|
||||||
bool Init(EGLConfig config);
|
|
||||||
EGLDisplay EGLGetDisplay(void);
|
|
||||||
EGLNativeWindowType CreateWindow(void);
|
|
||||||
void DestroyWindow(void);
|
|
||||||
void UpdateFPSDisplay(const char *text);
|
|
||||||
void ToggleFullscreen(bool fullscreen);
|
|
||||||
void SwapBuffers();
|
|
||||||
};
|
|
||||||
|
|
||||||
#include "GLInterface/EGL.h"
|
|
||||||
|
|
||||||
#if HAVE_WAYLAND
|
|
||||||
#include <wayland-egl.h>
|
|
||||||
#endif
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include "GLInterface/AGL.h"
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
#include "GLInterface/WGL.h"
|
|
||||||
#elif HAVE_X11
|
|
||||||
#include "GLInterface/GLX.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_WAYLAND
|
|
||||||
struct geometry {
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct xkb {
|
|
||||||
struct xkb_context *context;
|
|
||||||
struct xkb_keymap *keymap;
|
|
||||||
struct xkb_state *state;
|
|
||||||
xkb_mod_mask_t control_mask;
|
|
||||||
xkb_mod_mask_t alt_mask;
|
|
||||||
xkb_mod_mask_t shift_mask;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
// Currently Wayland/EGL and X11/EGL platforms are supported.
|
|
||||||
// The platform may be spelected at run time by setting the
|
|
||||||
// environment variable DOLPHIN_EGL_PLATFORM to "wayland" or "x11".
|
|
||||||
#if USE_EGL
|
|
||||||
EGLSurface egl_surf;
|
|
||||||
EGLContext egl_ctx;
|
|
||||||
EGLDisplay egl_dpy;
|
|
||||||
enum egl_platform platform;
|
|
||||||
#endif
|
|
||||||
EGLNativeWindowType native_window;
|
|
||||||
#if HAVE_WAYLAND
|
|
||||||
struct wl_display *wl_display;
|
|
||||||
struct wl_registry *wl_registry;
|
|
||||||
struct wl_compositor *wl_compositor;
|
|
||||||
struct wl_shell *wl_shell;
|
|
||||||
struct wl_seat *wl_seat;
|
|
||||||
struct {
|
|
||||||
struct wl_pointer *wl_pointer;
|
|
||||||
uint32_t serial;
|
|
||||||
} pointer;
|
|
||||||
struct {
|
|
||||||
struct wl_keyboard *wl_keyboard;
|
|
||||||
struct xkb xkb;
|
|
||||||
uint32_t modifiers;
|
|
||||||
} keyboard;
|
|
||||||
struct wl_shm *wl_shm;
|
|
||||||
struct wl_cursor_theme *wl_cursor_theme;
|
|
||||||
struct wl_cursor *wl_cursor;
|
|
||||||
struct wl_surface *wl_cursor_surface;
|
|
||||||
struct geometry geometry, window_size;
|
|
||||||
struct wl_egl_window *wl_egl_native;
|
|
||||||
struct wl_surface *wl_surface;
|
|
||||||
struct wl_shell_surface *wl_shell_surface;
|
|
||||||
struct wl_callback *wl_callback;
|
|
||||||
bool fullscreen, running;
|
|
||||||
#endif
|
|
||||||
#if HAVE_X11
|
|
||||||
int screen;
|
|
||||||
// dpy used for egl/glx stuff, evdpy for window events etc.
|
|
||||||
// evdpy is to be used by XEventThread only
|
|
||||||
Display *dpy;
|
|
||||||
Display *evdpy;
|
|
||||||
#if !USE_EGL
|
|
||||||
GLXContext ctx;
|
|
||||||
#endif
|
|
||||||
Window win;
|
|
||||||
Window parent;
|
|
||||||
XVisualInfo *vi;
|
|
||||||
XSetWindowAttributes attr;
|
|
||||||
std::thread xEventThread;
|
|
||||||
int x, y;
|
|
||||||
unsigned int width, height;
|
|
||||||
#elif defined(ANDROID)
|
|
||||||
unsigned int width, height;
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
NSWindow *cocoaWin;
|
|
||||||
NSOpenGLContext *cocoaCtx;
|
|
||||||
#endif
|
|
||||||
} GLWindow;
|
|
||||||
|
|
||||||
extern cInterfaceBase *GLInterface;
|
|
||||||
extern GLWindow GLWin;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -360,11 +360,7 @@ bool cWaylandInterface::Initialize(void *config)
|
||||||
|
|
||||||
void *cWaylandInterface::EGLGetDisplay(void)
|
void *cWaylandInterface::EGLGetDisplay(void)
|
||||||
{
|
{
|
||||||
#if HAVE_X11
|
|
||||||
return eglGetDisplay((_XDisplay *) GLWin.wl_display);
|
|
||||||
#else
|
|
||||||
return eglGetDisplay(GLWin.wl_display);
|
return eglGetDisplay(GLWin.wl_display);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cWaylandInterface::CreateWindow(void)
|
void *cWaylandInterface::CreateWindow(void)
|
||||||
|
@ -393,9 +389,6 @@ void cWaylandInterface::DestroyWindow(void)
|
||||||
|
|
||||||
wl_shell_surface_destroy(GLWin.wl_shell_surface);
|
wl_shell_surface_destroy(GLWin.wl_shell_surface);
|
||||||
wl_surface_destroy(GLWin.wl_surface);
|
wl_surface_destroy(GLWin.wl_surface);
|
||||||
|
|
||||||
if (GLWin.wl_callback)
|
|
||||||
wl_callback_destroy(GLWin.wl_callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cWaylandInterface::UpdateFPSDisplay(const char *text)
|
void cWaylandInterface::UpdateFPSDisplay(const char *text)
|
||||||
|
|
|
@ -74,7 +74,11 @@ bool cXInterface::Initialize(void *config)
|
||||||
|
|
||||||
void *cXInterface::EGLGetDisplay(void)
|
void *cXInterface::EGLGetDisplay(void)
|
||||||
{
|
{
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
return eglGetDisplay((wl_display *) GLWin.dpy);
|
||||||
|
#else
|
||||||
return eglGetDisplay(GLWin.dpy);
|
return eglGetDisplay(GLWin.dpy);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cXInterface::CreateWindow(void)
|
void *cXInterface::CreateWindow(void)
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#if HAVE_WAYLAND
|
#if HAVE_WAYLAND
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include "GLInterface/Platform.h"
|
#include "GLInterface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "ControllerInterface.h"
|
#include "ControllerInterface.h"
|
||||||
|
|
||||||
#if USE_EGL
|
#if USE_EGL
|
||||||
#include "GLInterface/Platform.h"
|
#include "GLInterface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CIFACE_USE_XINPUT
|
#ifdef CIFACE_USE_XINPUT
|
||||||
|
|
Loading…
Reference in New Issue