medfall

A super great game engine
Log | Files | Refs

egl_context.h (8506B)


      1 //========================================================================
      2 // GLFW 3.3 EGL - www.glfw.org
      3 //------------------------------------------------------------------------
      4 // Copyright (c) 2002-2006 Marcus Geelnard
      5 // Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
      6 //
      7 // This software is provided 'as-is', without any express or implied
      8 // warranty. In no event will the authors be held liable for any damages
      9 // arising from the use of this software.
     10 //
     11 // Permission is granted to anyone to use this software for any purpose,
     12 // including commercial applications, and to alter it and redistribute it
     13 // freely, subject to the following restrictions:
     14 //
     15 // 1. The origin of this software must not be misrepresented; you must not
     16 //    claim that you wrote the original software. If you use this software
     17 //    in a product, an acknowledgment in the product documentation would
     18 //    be appreciated but is not required.
     19 //
     20 // 2. Altered source versions must be plainly marked as such, and must not
     21 //    be misrepresented as being the original software.
     22 //
     23 // 3. This notice may not be removed or altered from any source
     24 //    distribution.
     25 //
     26 //========================================================================
     27 
     28 #if defined(_GLFW_USE_EGLPLATFORM_H)
     29  #include <EGL/eglplatform.h>
     30 #elif defined(_GLFW_WIN32)
     31  #define EGLAPIENTRY __stdcall
     32 typedef HDC EGLNativeDisplayType;
     33 typedef HWND EGLNativeWindowType;
     34 #elif defined(_GLFW_COCOA)
     35  #define EGLAPIENTRY
     36 typedef void* EGLNativeDisplayType;
     37 typedef id EGLNativeWindowType;
     38 #elif defined(_GLFW_X11)
     39  #define EGLAPIENTRY
     40 typedef Display* EGLNativeDisplayType;
     41 typedef Window EGLNativeWindowType;
     42 #elif defined(_GLFW_WAYLAND)
     43  #define EGLAPIENTRY
     44 typedef struct wl_display* EGLNativeDisplayType;
     45 typedef struct wl_egl_window* EGLNativeWindowType;
     46 #elif defined(_GLFW_MIR)
     47  #define EGLAPIENTRY
     48 typedef MirEGLNativeDisplayType EGLNativeDisplayType;
     49 typedef MirEGLNativeWindowType EGLNativeWindowType;
     50 #else
     51  #error "No supported EGL platform selected"
     52 #endif
     53 
     54 #define EGL_SUCCESS	0x3000
     55 #define EGL_NOT_INITIALIZED	0x3001
     56 #define EGL_BAD_ACCESS 0x3002
     57 #define EGL_BAD_ALLOC 0x3003
     58 #define EGL_BAD_ATTRIBUTE 0x3004
     59 #define EGL_BAD_CONFIG 0x3005
     60 #define EGL_BAD_CONTEXT	0x3006
     61 #define EGL_BAD_CURRENT_SURFACE	0x3007
     62 #define EGL_BAD_DISPLAY	0x3008
     63 #define EGL_BAD_MATCH 0x3009
     64 #define EGL_BAD_NATIVE_PIXMAP 0x300a
     65 #define EGL_BAD_NATIVE_WINDOW 0x300b
     66 #define EGL_BAD_PARAMETER 0x300c
     67 #define EGL_BAD_SURFACE	0x300d
     68 #define EGL_CONTEXT_LOST 0x300e
     69 #define EGL_COLOR_BUFFER_TYPE 0x303f
     70 #define EGL_RGB_BUFFER 0x308e
     71 #define EGL_SURFACE_TYPE 0x3033
     72 #define EGL_WINDOW_BIT 0x0004
     73 #define EGL_RENDERABLE_TYPE	0x3040
     74 #define EGL_OPENGL_ES_BIT 0x0001
     75 #define EGL_OPENGL_ES2_BIT 0x0004
     76 #define EGL_OPENGL_BIT 0x0008
     77 #define EGL_ALPHA_SIZE 0x3021
     78 #define EGL_BLUE_SIZE 0x3022
     79 #define EGL_GREEN_SIZE 0x3023
     80 #define EGL_RED_SIZE 0x3024
     81 #define EGL_DEPTH_SIZE 0x3025
     82 #define EGL_STENCIL_SIZE 0x3026
     83 #define EGL_SAMPLES	0x3031
     84 #define EGL_OPENGL_ES_API 0x30a0
     85 #define EGL_OPENGL_API 0x30a2
     86 #define EGL_NONE 0x3038
     87 #define EGL_EXTENSIONS 0x3055
     88 #define EGL_CONTEXT_CLIENT_VERSION 0x3098
     89 #define EGL_NATIVE_VISUAL_ID 0x302e
     90 #define EGL_NO_SURFACE ((EGLSurface) 0)
     91 #define EGL_NO_DISPLAY ((EGLDisplay) 0)
     92 #define EGL_NO_CONTEXT ((EGLContext) 0)
     93 #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
     94 
     95 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
     96 #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
     97 #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
     98 #define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
     99 #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
    100 #define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
    101 #define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
    102 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
    103 #define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
    104 #define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
    105 #define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
    106 #define EGL_CONTEXT_FLAGS_KHR 0x30fc
    107 #define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
    108 #define EGL_GL_COLORSPACE_KHR 0x309d
    109 #define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
    110 #define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
    111 #define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
    112 #define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
    113 
    114 typedef int EGLint;
    115 typedef unsigned int EGLBoolean;
    116 typedef unsigned int EGLenum;
    117 typedef void* EGLConfig;
    118 typedef void* EGLContext;
    119 typedef void* EGLDisplay;
    120 typedef void* EGLSurface;
    121 
    122 // EGL function pointer typedefs
    123 typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
    124 typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
    125 typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
    126 typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
    127 typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
    128 typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
    129 typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
    130 typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
    131 typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
    132 typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
    133 typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
    134 typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
    135 typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
    136 typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
    137 typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
    138 typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
    139 #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
    140 #define eglGetConfigs _glfw.egl.GetConfigs
    141 #define eglGetDisplay _glfw.egl.GetDisplay
    142 #define eglGetError _glfw.egl.GetError
    143 #define eglInitialize _glfw.egl.Initialize
    144 #define eglTerminate _glfw.egl.Terminate
    145 #define eglBindAPI _glfw.egl.BindAPI
    146 #define eglCreateContext _glfw.egl.CreateContext
    147 #define eglDestroySurface _glfw.egl.DestroySurface
    148 #define eglDestroyContext _glfw.egl.DestroyContext
    149 #define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
    150 #define eglMakeCurrent _glfw.egl.MakeCurrent
    151 #define eglSwapBuffers _glfw.egl.SwapBuffers
    152 #define eglSwapInterval _glfw.egl.SwapInterval
    153 #define eglQueryString _glfw.egl.QueryString
    154 #define eglGetProcAddress _glfw.egl.GetProcAddress
    155 
    156 #define _GLFW_EGL_CONTEXT_STATE            _GLFWcontextEGL egl
    157 #define _GLFW_EGL_LIBRARY_CONTEXT_STATE    _GLFWlibraryEGL egl
    158 
    159 
    160 // EGL-specific per-context data
    161 //
    162 typedef struct _GLFWcontextEGL
    163 {
    164    EGLConfig        config;
    165    EGLContext       handle;
    166    EGLSurface       surface;
    167 
    168    void*            client;
    169 
    170 } _GLFWcontextEGL;
    171 
    172 // EGL-specific global data
    173 //
    174 typedef struct _GLFWlibraryEGL
    175 {
    176     EGLDisplay      display;
    177     EGLint          major, minor;
    178     GLFWbool        prefix;
    179 
    180     GLFWbool        KHR_create_context;
    181     GLFWbool        KHR_create_context_no_error;
    182     GLFWbool        KHR_gl_colorspace;
    183     GLFWbool        KHR_get_all_proc_addresses;
    184     GLFWbool        KHR_context_flush_control;
    185 
    186     void*           handle;
    187 
    188     PFN_eglGetConfigAttrib      GetConfigAttrib;
    189     PFN_eglGetConfigs           GetConfigs;
    190     PFN_eglGetDisplay           GetDisplay;
    191     PFN_eglGetError             GetError;
    192     PFN_eglInitialize           Initialize;
    193     PFN_eglTerminate            Terminate;
    194     PFN_eglBindAPI              BindAPI;
    195     PFN_eglCreateContext        CreateContext;
    196     PFN_eglDestroySurface       DestroySurface;
    197     PFN_eglDestroyContext       DestroyContext;
    198     PFN_eglCreateWindowSurface  CreateWindowSurface;
    199     PFN_eglMakeCurrent          MakeCurrent;
    200     PFN_eglSwapBuffers          SwapBuffers;
    201     PFN_eglSwapInterval         SwapInterval;
    202     PFN_eglQueryString          QueryString;
    203     PFN_eglGetProcAddress       GetProcAddress;
    204 
    205 } _GLFWlibraryEGL;
    206 
    207 
    208 GLFWbool _glfwInitEGL(void);
    209 void _glfwTerminateEGL(void);
    210 GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
    211                                const _GLFWctxconfig* ctxconfig,
    212                                const _GLFWfbconfig* fbconfig);
    213 #if defined(_GLFW_X11)
    214 GLFWbool _glfwChooseVisualEGL(const _GLFWctxconfig* ctxconfig,
    215                               const _GLFWfbconfig* fbconfig,
    216                               Visual** visual, int* depth);
    217 #endif /*_GLFW_X11*/
    218