egl_context.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. //========================================================================
  2. // GLFW 3.4 EGL - www.glfw.org
  3. //------------------------------------------------------------------------
  4. // Copyright (c) 2002-2006 Marcus Geelnard
  5. // Copyright (c) 2006-2017 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. #if defined(_GLFW_WIN32)
  28. #define EGLAPIENTRY __stdcall
  29. #else
  30. #define EGLAPIENTRY
  31. #endif
  32. #define EGL_SUCCESS 0x3000
  33. #define EGL_NOT_INITIALIZED 0x3001
  34. #define EGL_BAD_ACCESS 0x3002
  35. #define EGL_BAD_ALLOC 0x3003
  36. #define EGL_BAD_ATTRIBUTE 0x3004
  37. #define EGL_BAD_CONFIG 0x3005
  38. #define EGL_BAD_CONTEXT 0x3006
  39. #define EGL_BAD_CURRENT_SURFACE 0x3007
  40. #define EGL_BAD_DISPLAY 0x3008
  41. #define EGL_BAD_MATCH 0x3009
  42. #define EGL_BAD_NATIVE_PIXMAP 0x300a
  43. #define EGL_BAD_NATIVE_WINDOW 0x300b
  44. #define EGL_BAD_PARAMETER 0x300c
  45. #define EGL_BAD_SURFACE 0x300d
  46. #define EGL_CONTEXT_LOST 0x300e
  47. #define EGL_COLOR_BUFFER_TYPE 0x303f
  48. #define EGL_RGB_BUFFER 0x308e
  49. #define EGL_SURFACE_TYPE 0x3033
  50. #define EGL_WINDOW_BIT 0x0004
  51. #define EGL_RENDERABLE_TYPE 0x3040
  52. #define EGL_OPENGL_ES_BIT 0x0001
  53. #define EGL_OPENGL_ES2_BIT 0x0004
  54. #define EGL_OPENGL_BIT 0x0008
  55. #define EGL_ALPHA_SIZE 0x3021
  56. #define EGL_BLUE_SIZE 0x3022
  57. #define EGL_GREEN_SIZE 0x3023
  58. #define EGL_RED_SIZE 0x3024
  59. #define EGL_DEPTH_SIZE 0x3025
  60. #define EGL_STENCIL_SIZE 0x3026
  61. #define EGL_SAMPLES 0x3031
  62. #define EGL_OPENGL_ES_API 0x30a0
  63. #define EGL_OPENGL_API 0x30a2
  64. #define EGL_NONE 0x3038
  65. #define EGL_EXTENSIONS 0x3055
  66. #define EGL_CONTEXT_CLIENT_VERSION 0x3098
  67. #define EGL_NATIVE_VISUAL_ID 0x302e
  68. #define EGL_NO_SURFACE ((EGLSurface) 0)
  69. #define EGL_NO_DISPLAY ((EGLDisplay) 0)
  70. #define EGL_NO_CONTEXT ((EGLContext) 0)
  71. #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
  72. #define EGL_MIN_SWAP_INTERVAL 0x303B
  73. #define EGL_MAX_SWAP_INTERVAL 0x303C
  74. #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
  75. #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
  76. #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
  77. #define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
  78. #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
  79. #define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
  80. #define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
  81. #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
  82. #define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
  83. #define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
  84. #define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
  85. #define EGL_CONTEXT_FLAGS_KHR 0x30fc
  86. #define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
  87. #define EGL_GL_COLORSPACE_KHR 0x309d
  88. #define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
  89. #define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
  90. #define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
  91. #define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
  92. #define EGL_PLATFORM_X11_EXT 0x31d5
  93. #define EGL_PLATFORM_WAYLAND_EXT 0x31d8
  94. #define EGL_PLATFORM_ANGLE_ANGLE 0x3202
  95. #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
  96. #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d
  97. #define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e
  98. #define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
  99. #define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
  100. #define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
  101. #define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
  102. #define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
  103. typedef int EGLint;
  104. typedef unsigned int EGLBoolean;
  105. typedef unsigned int EGLenum;
  106. typedef void* EGLConfig;
  107. typedef void* EGLContext;
  108. typedef void* EGLDisplay;
  109. typedef void* EGLSurface;
  110. typedef void* EGLNativeDisplayType;
  111. typedef void* EGLNativeWindowType;
  112. // EGL function pointer typedefs
  113. typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
  114. typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
  115. typedef EGLBoolean (EGLAPIENTRY * PFN_eglChooseConfig)(EGLDisplay,EGLint const*,EGLConfig*,EGLint,EGLint*);
  116. typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
  117. typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
  118. typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
  119. typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
  120. typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
  121. typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
  122. typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
  123. typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
  124. typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
  125. typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
  126. typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
  127. typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
  128. typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
  129. typedef const char* (EGLAPIENTRY * PFN_eglQuerySurface)(EGLDisplay,EGLSurface,EGLint,EGLint*);
  130. typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
  131. #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
  132. #define eglGetConfigs _glfw.egl.GetConfigs
  133. #define eglChooseConfig _glfw.egl.ChooseConfig
  134. #define eglGetDisplay _glfw.egl.GetDisplay
  135. #define eglGetError _glfw.egl.GetError
  136. #define eglInitialize _glfw.egl.Initialize
  137. #define eglTerminate _glfw.egl.Terminate
  138. #define eglBindAPI _glfw.egl.BindAPI
  139. #define eglCreateContext _glfw.egl.CreateContext
  140. #define eglDestroySurface _glfw.egl.DestroySurface
  141. #define eglDestroyContext _glfw.egl.DestroyContext
  142. #define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
  143. #define eglMakeCurrent _glfw.egl.MakeCurrent
  144. #define eglSwapBuffers _glfw.egl.SwapBuffers
  145. #define eglSwapInterval _glfw.egl.SwapInterval
  146. #define eglQueryString _glfw.egl.QueryString
  147. #define eglQuerySurface _glfw.egl.QuerySurface
  148. #define eglGetProcAddress _glfw.egl.GetProcAddress
  149. typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
  150. typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
  151. #define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
  152. #define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
  153. // EGL-specific per-context data
  154. //
  155. typedef struct _GLFWcontextEGL
  156. {
  157. EGLConfig config;
  158. EGLContext handle;
  159. EGLSurface surface;
  160. void* client;
  161. } _GLFWcontextEGL;
  162. // EGL-specific global data
  163. //
  164. typedef struct _GLFWlibraryEGL
  165. {
  166. EGLenum platform;
  167. EGLDisplay display;
  168. EGLint major, minor;
  169. bool prefix;
  170. bool KHR_create_context;
  171. bool KHR_create_context_no_error;
  172. bool KHR_gl_colorspace;
  173. bool KHR_get_all_proc_addresses;
  174. bool KHR_context_flush_control;
  175. bool EXT_client_extensions;
  176. bool EXT_platform_base;
  177. bool EXT_platform_x11;
  178. bool EXT_platform_wayland;
  179. bool EXT_present_opaque;
  180. bool ANGLE_platform_angle;
  181. bool ANGLE_platform_angle_opengl;
  182. bool ANGLE_platform_angle_d3d;
  183. bool ANGLE_platform_angle_vulkan;
  184. bool ANGLE_platform_angle_metal;
  185. void* handle;
  186. PFN_eglGetConfigAttrib GetConfigAttrib;
  187. PFN_eglGetConfigs GetConfigs;
  188. PFN_eglChooseConfig ChooseConfig;
  189. PFN_eglGetDisplay GetDisplay;
  190. PFN_eglGetError GetError;
  191. PFN_eglInitialize Initialize;
  192. PFN_eglTerminate Terminate;
  193. PFN_eglBindAPI BindAPI;
  194. PFN_eglCreateContext CreateContext;
  195. PFN_eglDestroySurface DestroySurface;
  196. PFN_eglDestroyContext DestroyContext;
  197. PFN_eglCreateWindowSurface CreateWindowSurface;
  198. PFN_eglMakeCurrent MakeCurrent;
  199. PFN_eglSwapBuffers SwapBuffers;
  200. PFN_eglSwapInterval SwapInterval;
  201. PFN_eglQueryString QueryString;
  202. PFN_eglQuerySurface QuerySurface;
  203. PFN_eglGetProcAddress GetProcAddress;
  204. PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
  205. PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
  206. } _GLFWlibraryEGL;
  207. bool _glfwInitEGL(void);
  208. void _glfwTerminateEGL(void);
  209. bool _glfwCreateContextEGL(_GLFWwindow* window,
  210. const _GLFWctxconfig* ctxconfig,
  211. const _GLFWfbconfig* fbconfig);
  212. #if defined(_GLFW_X11)
  213. bool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
  214. const _GLFWctxconfig* ctxconfig,
  215. const _GLFWfbconfig* fbconfig,
  216. Visual** visual, int* depth);
  217. #endif /*_GLFW_X11*/