2017-07-04 16:55:08 -04:00
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
|
|
// Copyright (C) 2016-2017 SuperTuxKart-Team
|
|
|
|
//
|
|
|
|
// 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 3
|
|
|
|
// of the License, 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 this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
2017-04-05 14:28:38 -04:00
|
|
|
|
2017-04-20 17:20:21 -04:00
|
|
|
#ifndef CONTEXT_EGL_HPP
|
|
|
|
#define CONTEXT_EGL_HPP
|
2017-04-05 14:28:38 -04:00
|
|
|
|
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
|
|
|
|
#if defined(_IRR_COMPILE_WITH_EGL_)
|
|
|
|
|
|
|
|
#include <EGL/egl.h>
|
2017-04-21 02:51:54 -04:00
|
|
|
|
|
|
|
#ifndef EGL_CONTEXT_MAJOR_VERSION
|
|
|
|
#define EGL_CONTEXT_MAJOR_VERSION 0x3098
|
|
|
|
#endif
|
|
|
|
#ifndef EGL_CONTEXT_MINOR_VERSION
|
|
|
|
#define EGL_CONTEXT_MINOR_VERSION 0x30FB
|
|
|
|
#endif
|
2017-09-17 15:51:07 -04:00
|
|
|
#ifndef EGL_GL_COLORSPACE
|
|
|
|
#define EGL_GL_COLORSPACE 0x309D
|
|
|
|
#endif
|
|
|
|
#ifndef EGL_GL_COLORSPACE_SRGB
|
|
|
|
#define EGL_GL_COLORSPACE_SRGB 0x3089
|
|
|
|
#endif
|
|
|
|
#ifndef EGL_GL_COLORSPACE_LINEAR
|
|
|
|
#define EGL_GL_COLORSPACE_LINEAR 0x308A
|
|
|
|
#endif
|
2018-01-06 17:06:12 -05:00
|
|
|
#ifndef EGL_PLATFORM_ANDROID
|
|
|
|
#define EGL_PLATFORM_ANDROID 0x3141
|
|
|
|
#endif
|
|
|
|
#ifndef EGL_PLATFORM_GBM
|
|
|
|
#define EGL_PLATFORM_GBM 0x31D7
|
|
|
|
#endif
|
|
|
|
#ifndef EGL_PLATFORM_WAYLAND
|
|
|
|
#define EGL_PLATFORM_WAYLAND 0x31D8
|
|
|
|
#endif
|
|
|
|
#ifndef EGL_PLATFORM_X11
|
|
|
|
#define EGL_PLATFORM_X11 0x31D5
|
|
|
|
#endif
|
2017-04-05 14:28:38 -04:00
|
|
|
|
2017-04-20 17:20:21 -04:00
|
|
|
enum ContextEGLOpenGLAPI
|
|
|
|
{
|
|
|
|
CEGL_API_OPENGL,
|
|
|
|
CEGL_API_OPENGL_ES
|
|
|
|
};
|
2017-04-05 14:28:38 -04:00
|
|
|
|
2017-04-20 17:20:21 -04:00
|
|
|
enum ContextEGLSurfaceType
|
2017-04-05 14:28:38 -04:00
|
|
|
{
|
2017-04-20 17:20:21 -04:00
|
|
|
CEGL_SURFACE_WINDOW,
|
|
|
|
CEGL_SURFACE_PBUFFER
|
|
|
|
};
|
|
|
|
|
2018-01-06 17:06:12 -05:00
|
|
|
enum ContextEGLPlatform
|
|
|
|
{
|
|
|
|
CEGL_PLATFORM_ANDROID,
|
|
|
|
CEGL_PLATFORM_GBM,
|
|
|
|
CEGL_PLATFORM_WAYLAND,
|
|
|
|
CEGL_PLATFORM_X11,
|
|
|
|
CEGL_PLATFORM_DEFAULT
|
|
|
|
};
|
|
|
|
|
2017-04-20 17:20:21 -04:00
|
|
|
struct ContextEGLParams
|
2017-04-05 14:28:38 -04:00
|
|
|
{
|
2017-04-20 17:20:21 -04:00
|
|
|
ContextEGLOpenGLAPI opengl_api;
|
|
|
|
ContextEGLSurfaceType surface_type;
|
2018-01-06 17:06:12 -05:00
|
|
|
ContextEGLPlatform platform;
|
2017-04-20 17:20:21 -04:00
|
|
|
EGLNativeWindowType window;
|
|
|
|
EGLNativeDisplayType display;
|
|
|
|
bool force_legacy_device;
|
2017-09-17 15:51:07 -04:00
|
|
|
bool handle_srgb;
|
2017-04-20 17:20:21 -04:00
|
|
|
bool with_alpha_channel;
|
2019-09-27 18:55:18 -04:00
|
|
|
int swap_interval;
|
2017-04-20 17:20:21 -04:00
|
|
|
int pbuffer_width;
|
|
|
|
int pbuffer_height;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ContextManagerEGL
|
2017-04-05 14:28:38 -04:00
|
|
|
{
|
|
|
|
private:
|
2017-04-21 02:51:54 -04:00
|
|
|
EGLNativeWindowType m_egl_window;
|
2017-04-20 17:20:21 -04:00
|
|
|
EGLDisplay m_egl_display;
|
|
|
|
EGLSurface m_egl_surface;
|
|
|
|
EGLContext m_egl_context;
|
|
|
|
EGLConfig m_egl_config;
|
|
|
|
|
|
|
|
ContextEGLParams m_creation_params;
|
|
|
|
bool m_is_legacy_device;
|
|
|
|
bool m_initialized;
|
|
|
|
int m_egl_version;
|
2017-04-05 14:28:38 -04:00
|
|
|
|
2018-01-06 20:16:13 -05:00
|
|
|
typedef EGLDisplay (*eglGetPlatformDisplay_t) (EGLenum, void*, const EGLint*);
|
|
|
|
eglGetPlatformDisplay_t eglGetPlatformDisplay;
|
|
|
|
|
|
|
|
bool initExtensions();
|
2017-04-20 17:20:21 -04:00
|
|
|
bool initDisplay();
|
|
|
|
bool chooseConfig();
|
|
|
|
bool createSurface();
|
|
|
|
bool createContext();
|
|
|
|
bool hasEGLExtension(const char* extension);
|
|
|
|
bool checkEGLError();
|
2017-04-05 14:28:38 -04:00
|
|
|
|
|
|
|
public:
|
2017-04-20 17:20:21 -04:00
|
|
|
ContextManagerEGL();
|
|
|
|
~ContextManagerEGL();
|
2017-04-05 14:28:38 -04:00
|
|
|
|
2017-04-20 17:20:21 -04:00
|
|
|
bool init(const ContextEGLParams& params);
|
|
|
|
void close();
|
2017-04-05 14:28:38 -04:00
|
|
|
|
2017-04-20 17:20:21 -04:00
|
|
|
void reloadEGLSurface(void* window);
|
|
|
|
bool swapBuffers();
|
2017-05-11 18:57:01 -04:00
|
|
|
bool makeCurrent();
|
2017-04-20 17:20:21 -04:00
|
|
|
bool isLegacyDevice() {return m_is_legacy_device;}
|
|
|
|
bool getSurfaceDimensions(int* width, int* height);
|
|
|
|
};
|
2017-04-05 14:28:38 -04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|