2013-01-17 16:58:48 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007-2012 Gabest
|
|
|
|
* http://www.gabest.org
|
|
|
|
*
|
|
|
|
* 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; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* 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 for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "GSWnd.h"
|
|
|
|
|
2016-05-01 09:43:18 +00:00
|
|
|
#if defined(__unix__) && defined(EGL_SUPPORTED)
|
2013-01-17 16:58:48 +00:00
|
|
|
#include <EGL/egl.h>
|
|
|
|
#include <EGL/eglext.h>
|
|
|
|
|
2017-04-29 08:39:53 +00:00
|
|
|
#define GS_EGL_X11 1
|
|
|
|
#define GS_EGL_WL 0
|
|
|
|
|
2013-06-16 08:43:50 +00:00
|
|
|
class GSWndEGL : public GSWndGL
|
2013-01-17 16:58:48 +00:00
|
|
|
{
|
2017-04-29 08:39:53 +00:00
|
|
|
void *m_native_window;
|
2013-01-17 16:58:48 +00:00
|
|
|
|
|
|
|
EGLDisplay m_eglDisplay;
|
|
|
|
EGLSurface m_eglSurface;
|
|
|
|
EGLContext m_eglContext;
|
|
|
|
|
2017-04-29 08:39:53 +00:00
|
|
|
int m_platform;
|
|
|
|
|
2013-06-16 09:40:38 +00:00
|
|
|
void CreateContext(int major, int minor);
|
2016-10-21 15:32:56 +00:00
|
|
|
void BindAPI();
|
2013-01-17 16:58:48 +00:00
|
|
|
|
2013-06-16 09:40:38 +00:00
|
|
|
void OpenEGLDisplay();
|
2013-01-17 16:58:48 +00:00
|
|
|
void CloseEGLDisplay();
|
|
|
|
|
|
|
|
public:
|
2017-04-29 08:39:53 +00:00
|
|
|
GSWndEGL(int platform);
|
2013-01-17 16:58:48 +00:00
|
|
|
virtual ~GSWndEGL() {};
|
|
|
|
|
2017-04-29 08:39:53 +00:00
|
|
|
bool Create(const string& title, int w, int h) final;
|
|
|
|
bool Attach(void* handle, bool managed = true) final;
|
|
|
|
void Detach() final;
|
|
|
|
|
|
|
|
virtual void *CreateNativeDisplay() = 0;
|
|
|
|
virtual void *CreateNativeWindow(int w, int h) = 0; // GSopen1/PSX API
|
|
|
|
virtual void *AttachNativeWindow(void *handle) = 0;
|
|
|
|
virtual void DestroyNativeResources() = 0;
|
2013-01-17 16:58:48 +00:00
|
|
|
|
|
|
|
GSVector4i GetClientRect();
|
2017-04-29 08:39:53 +00:00
|
|
|
virtual bool SetWindowText(const char* title) = 0; // GSopen1/PSX API
|
|
|
|
|
|
|
|
void AttachContext() final;
|
|
|
|
void DetachContext() final;
|
|
|
|
void* GetProcAddress(const char* name, bool opt = false) final;
|
|
|
|
|
|
|
|
void Flip() final;
|
2017-05-21 20:14:34 +00:00
|
|
|
void SetVSync(int vsync) final;
|
2017-04-29 08:39:53 +00:00
|
|
|
|
|
|
|
// Deprecated API
|
|
|
|
void Show() final {};
|
|
|
|
void Hide() final {};
|
|
|
|
void HideFrame() final {}; // DX9 API
|
|
|
|
|
|
|
|
virtual void* GetDisplay() = 0; // GSopen1 API
|
|
|
|
virtual void* GetHandle() = 0; // DX API
|
|
|
|
|
|
|
|
// Static to allow to query supported the platform
|
|
|
|
// before object creation
|
|
|
|
static int SelectPlatform();
|
|
|
|
};
|
|
|
|
|
|
|
|
#if GS_EGL_X11
|
|
|
|
|
|
|
|
#include <xcb/xcb.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xlib-xcb.h>
|
|
|
|
|
|
|
|
class GSWndEGL_X11 : public GSWndEGL
|
|
|
|
{
|
|
|
|
Display *m_NativeDisplay;
|
|
|
|
Window m_NativeWindow;
|
2013-01-17 16:58:48 +00:00
|
|
|
|
2017-04-29 08:39:53 +00:00
|
|
|
public:
|
|
|
|
GSWndEGL_X11();
|
|
|
|
virtual ~GSWndEGL_X11() {};
|
2013-01-17 16:58:48 +00:00
|
|
|
|
2017-04-29 08:39:53 +00:00
|
|
|
void* GetDisplay() final { return (void*)m_NativeDisplay;}
|
|
|
|
void* GetHandle() final {return (void*)&m_NativeWindow;}
|
|
|
|
|
|
|
|
void *CreateNativeDisplay() final;
|
|
|
|
void *CreateNativeWindow(int w, int h) final;
|
|
|
|
void *AttachNativeWindow(void *handle) final;
|
|
|
|
void DestroyNativeResources() final;
|
|
|
|
|
|
|
|
bool SetWindowText(const char* title) final;
|
2013-01-17 16:58:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2017-04-29 08:39:53 +00:00
|
|
|
|
|
|
|
#if GS_EGL_WL
|
|
|
|
|
|
|
|
// Which include ?
|
|
|
|
#include <wayland-client.h>
|
|
|
|
#include <wayland-server.h>
|
|
|
|
#include <wayland-client-protocol.h>
|
|
|
|
#include <wayland-egl.h>
|
|
|
|
|
|
|
|
class GSWndEGL_WL : public GSWndEGL
|
|
|
|
{
|
|
|
|
wl_display *m_NativeDisplay;
|
|
|
|
wl_egl_window *m_NativeWindow;
|
|
|
|
|
|
|
|
public:
|
|
|
|
GSWndEGL_WL();
|
|
|
|
virtual ~GSWndEGL_WL() {};
|
|
|
|
|
|
|
|
void* GetDisplay() final { return (void*)m_NativeDisplay;}
|
|
|
|
void* GetHandle() final {return (void*)m_NativeWindow;}
|
|
|
|
|
|
|
|
void *CreateNativeDisplay() final;
|
|
|
|
void *CreateNativeWindow(int w, int h) final;
|
|
|
|
void *AttachNativeWindow(void *handle) final;
|
|
|
|
void DestroyNativeResources() final;
|
|
|
|
|
|
|
|
bool SetWindowText(const char* title) final;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|