• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //========================================================================
2 // GLFW 3.2 EGL - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2002-2006 Marcus Geelnard
5 // Copyright (c) 2006-2016 Camilla Berglund <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 #ifndef _glfw3_egl_context_h_
29 #define _glfw3_egl_context_h_
30 
31 #if defined(_GLFW_USE_EGLPLATFORM_H)
32  #include <EGL/eglplatform.h>
33 #elif defined(_GLFW_WIN32)
34  #define EGLAPIENTRY __stdcall
35 typedef HDC EGLNativeDisplayType;
36 typedef HWND EGLNativeWindowType;
37 #elif defined(_GLFW_X11)
38  #define EGLAPIENTRY
39 typedef Display* EGLNativeDisplayType;
40 typedef Window EGLNativeWindowType;
41 #elif defined(_GLFW_WAYLAND)
42  #define EGLAPIENTRY
43 typedef struct wl_display* EGLNativeDisplayType;
44 typedef struct wl_egl_window* EGLNativeWindowType;
45 #elif defined(_GLFW_MIR)
46  #define EGLAPIENTRY
47 typedef MirEGLNativeDisplayType EGLNativeDisplayType;
48 typedef MirEGLNativeWindowType EGLNativeWindowType;
49 #else
50  #error "No supported EGL platform selected"
51 #endif
52 
53 #define EGL_SUCCESS	0x3000
54 #define EGL_NOT_INITIALIZED	0x3001
55 #define EGL_BAD_ACCESS 0x3002
56 #define EGL_BAD_ALLOC 0x3003
57 #define EGL_BAD_ATTRIBUTE 0x3004
58 #define EGL_BAD_CONFIG 0x3005
59 #define EGL_BAD_CONTEXT	0x3006
60 #define EGL_BAD_CURRENT_SURFACE	0x3007
61 #define EGL_BAD_DISPLAY	0x3008
62 #define EGL_BAD_MATCH 0x3009
63 #define EGL_BAD_NATIVE_PIXMAP 0x300a
64 #define EGL_BAD_NATIVE_WINDOW 0x300b
65 #define EGL_BAD_PARAMETER 0x300c
66 #define EGL_BAD_SURFACE	0x300d
67 #define EGL_CONTEXT_LOST 0x300e
68 #define EGL_COLOR_BUFFER_TYPE 0x303f
69 #define EGL_RGB_BUFFER 0x308e
70 #define EGL_SURFACE_TYPE 0x3033
71 #define EGL_WINDOW_BIT 0x0004
72 #define EGL_RENDERABLE_TYPE	0x3040
73 #define EGL_OPENGL_ES_BIT 0x0001
74 #define EGL_OPENGL_ES2_BIT 0x0004
75 #define EGL_OPENGL_BIT 0x0008
76 #define EGL_ALPHA_SIZE 0x3021
77 #define EGL_BLUE_SIZE 0x3022
78 #define EGL_GREEN_SIZE 0x3023
79 #define EGL_RED_SIZE 0x3024
80 #define EGL_DEPTH_SIZE 0x3025
81 #define EGL_STENCIL_SIZE 0x3026
82 #define EGL_SAMPLES	0x3031
83 #define EGL_OPENGL_ES_API 0x30a0
84 #define EGL_OPENGL_API 0x30a2
85 #define EGL_NONE 0x3038
86 #define EGL_EXTENSIONS 0x3055
87 #define EGL_CONTEXT_CLIENT_VERSION 0x3098
88 #define EGL_NATIVE_VISUAL_ID 0x302e
89 #define EGL_NO_SURFACE ((EGLSurface) 0)
90 #define EGL_NO_DISPLAY ((EGLDisplay) 0)
91 #define EGL_NO_CONTEXT ((EGLContext) 0)
92 #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
93 
94 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
95 #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
96 #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
97 #define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
98 #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
99 #define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
100 #define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
101 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
102 #define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
103 #define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
104 #define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
105 #define EGL_CONTEXT_FLAGS_KHR 0x30fc
106 #define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
107 #define EGL_GL_COLORSPACE_KHR 0x309d
108 #define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
109 
110 typedef int EGLint;
111 typedef unsigned int EGLBoolean;
112 typedef unsigned int EGLenum;
113 typedef void* EGLConfig;
114 typedef void* EGLContext;
115 typedef void* EGLDisplay;
116 typedef void* EGLSurface;
117 
118 // EGL function pointer typedefs
119 typedef EGLBoolean (EGLAPIENTRY * PFNEGLGETCONFIGATTRIBPROC)(EGLDisplay,EGLConfig,EGLint,EGLint*);
120 typedef EGLBoolean (EGLAPIENTRY * PFNEGLGETCONFIGSPROC)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
121 typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType);
122 typedef EGLint (EGLAPIENTRY * PFNEGLGETERRORPROC)(void);
123 typedef EGLBoolean (EGLAPIENTRY * PFNEGLINITIALIZEPROC)(EGLDisplay,EGLint*,EGLint*);
124 typedef EGLBoolean (EGLAPIENTRY * PFNEGLTERMINATEPROC)(EGLDisplay);
125 typedef EGLBoolean (EGLAPIENTRY * PFNEGLBINDAPIPROC)(EGLenum);
126 typedef EGLContext (EGLAPIENTRY * PFNEGLCREATECONTEXTPROC)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
127 typedef EGLBoolean (EGLAPIENTRY * PFNEGLDESTROYSURFACEPROC)(EGLDisplay,EGLSurface);
128 typedef EGLBoolean (EGLAPIENTRY * PFNEGLDESTROYCONTEXTPROC)(EGLDisplay,EGLContext);
129 typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
130 typedef EGLBoolean (EGLAPIENTRY * PFNEGLMAKECURRENTPROC)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
131 typedef EGLBoolean (EGLAPIENTRY * PFNEGLSWAPBUFFERSPROC)(EGLDisplay,EGLSurface);
132 typedef EGLBoolean (EGLAPIENTRY * PFNEGLSWAPINTERVALPROC)(EGLDisplay,EGLint);
133 typedef const char* (EGLAPIENTRY * PFNEGLQUERYSTRINGPROC)(EGLDisplay,EGLint);
134 typedef GLFWglproc (EGLAPIENTRY * PFNEGLGETPROCADDRESSPROC)(const char*);
135 #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
136 #define eglGetConfigs _glfw.egl.GetConfigs
137 #define eglGetDisplay _glfw.egl.GetDisplay
138 #define eglGetError _glfw.egl.GetError
139 #define eglInitialize _glfw.egl.Initialize
140 #define eglTerminate _glfw.egl.Terminate
141 #define eglBindAPI _glfw.egl.BindAPI
142 #define eglCreateContext _glfw.egl.CreateContext
143 #define eglDestroySurface _glfw.egl.DestroySurface
144 #define eglDestroyContext _glfw.egl.DestroyContext
145 #define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
146 #define eglMakeCurrent _glfw.egl.MakeCurrent
147 #define eglSwapBuffers _glfw.egl.SwapBuffers
148 #define eglSwapInterval _glfw.egl.SwapInterval
149 #define eglQueryString _glfw.egl.QueryString
150 #define eglGetProcAddress _glfw.egl.GetProcAddress
151 
152 #define _GLFW_EGL_CONTEXT_STATE            _GLFWcontextEGL egl
153 #define _GLFW_EGL_LIBRARY_CONTEXT_STATE    _GLFWlibraryEGL egl
154 
155 
156 // EGL-specific per-context data
157 //
158 typedef struct _GLFWcontextEGL
159 {
160    EGLConfig        config;
161    EGLContext       handle;
162    EGLSurface       surface;
163 
164    void*            client;
165 
166 } _GLFWcontextEGL;
167 
168 // EGL-specific global data
169 //
170 typedef struct _GLFWlibraryEGL
171 {
172     EGLDisplay      display;
173     EGLint          major, minor;
174     GLFWbool        prefix;
175 
176     GLFWbool        KHR_create_context;
177     GLFWbool        KHR_create_context_no_error;
178     GLFWbool        KHR_gl_colorspace;
179 
180     void*           handle;
181 
182     PFNEGLGETCONFIGATTRIBPROC       GetConfigAttrib;
183     PFNEGLGETCONFIGSPROC            GetConfigs;
184     PFNEGLGETDISPLAYPROC            GetDisplay;
185     PFNEGLGETERRORPROC              GetError;
186     PFNEGLINITIALIZEPROC            Initialize;
187     PFNEGLTERMINATEPROC             Terminate;
188     PFNEGLBINDAPIPROC               BindAPI;
189     PFNEGLCREATECONTEXTPROC         CreateContext;
190     PFNEGLDESTROYSURFACEPROC        DestroySurface;
191     PFNEGLDESTROYCONTEXTPROC        DestroyContext;
192     PFNEGLCREATEWINDOWSURFACEPROC   CreateWindowSurface;
193     PFNEGLMAKECURRENTPROC           MakeCurrent;
194     PFNEGLSWAPBUFFERSPROC           SwapBuffers;
195     PFNEGLSWAPINTERVALPROC          SwapInterval;
196     PFNEGLQUERYSTRINGPROC           QueryString;
197     PFNEGLGETPROCADDRESSPROC        GetProcAddress;
198 
199 } _GLFWlibraryEGL;
200 
201 
202 GLFWbool _glfwInitEGL(void);
203 void _glfwTerminateEGL(void);
204 GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
205                                const _GLFWctxconfig* ctxconfig,
206                                const _GLFWfbconfig* fbconfig);
207 #if defined(_GLFW_X11)
208 GLFWbool _glfwChooseVisualEGL(const _GLFWctxconfig* ctxconfig,
209                               const _GLFWfbconfig* fbconfig,
210                               Visual** visual, int* depth);
211 #endif /*_GLFW_X11*/
212 
213 #endif // _glfw3_egl_context_h_
214