SDL  2.0
SDL_egl.c
Go to the documentation of this file.
1 /*
2  * Simple DirectMedia Layer
3  * Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #include "../SDL_internal.h"
22 
23 #if SDL_VIDEO_OPENGL_EGL
24 
25 #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
26 #include "../core/windows/SDL_windows.h"
27 #endif
28 #if SDL_VIDEO_DRIVER_ANDROID
29 #include <android/native_window.h>
30 #include "../core/android/SDL_android.h"
31 #endif
32 
33 #include "SDL_sysvideo.h"
34 #include "SDL_log.h"
35 #include "SDL_egl_c.h"
36 #include "SDL_loadso.h"
37 #include "SDL_hints.h"
38 
39 #ifdef EGL_KHR_create_context
40 /* EGL_OPENGL_ES3_BIT_KHR was added in version 13 of the extension. */
41 #ifndef EGL_OPENGL_ES3_BIT_KHR
42 #define EGL_OPENGL_ES3_BIT_KHR 0x00000040
43 #endif
44 #endif /* EGL_KHR_create_context */
45 
46 #if SDL_VIDEO_DRIVER_RPI
47 /* Raspbian places the OpenGL ES/EGL binaries in a non standard path */
48 #define DEFAULT_EGL ( vc4 ? "libEGL.so.1" : "libbrcmEGL.so" )
49 #define DEFAULT_OGL_ES2 ( vc4 ? "libGLESv2.so.2" : "libbrcmGLESv2.so" )
50 #define ALT_EGL "libEGL.so"
51 #define ALT_OGL_ES2 "libGLESv2.so"
52 #define DEFAULT_OGL_ES_PVR ( vc4 ? "libGLES_CM.so.1" : "libbrcmGLESv2.so" )
53 #define DEFAULT_OGL_ES ( vc4 ? "libGLESv1_CM.so.1" : "libbrcmGLESv2.so" )
54 
55 #elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
56 /* Android */
57 #define DEFAULT_EGL "libEGL.so"
58 #define DEFAULT_OGL_ES2 "libGLESv2.so"
59 #define DEFAULT_OGL_ES_PVR "libGLES_CM.so"
60 #define DEFAULT_OGL_ES "libGLESv1_CM.so"
61 
62 #elif SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
63 /* EGL AND OpenGL ES support via ANGLE */
64 #define DEFAULT_EGL "libEGL.dll"
65 #define DEFAULT_OGL_ES2 "libGLESv2.dll"
66 #define DEFAULT_OGL_ES_PVR "libGLES_CM.dll"
67 #define DEFAULT_OGL_ES "libGLESv1_CM.dll"
68 
69 #elif SDL_VIDEO_DRIVER_COCOA
70 /* EGL AND OpenGL ES support via ANGLE */
71 #define DEFAULT_EGL "libEGL.dylib"
72 #define DEFAULT_OGL_ES2 "libGLESv2.dylib"
73 #define DEFAULT_OGL_ES_PVR "libGLES_CM.dylib" //???
74 #define DEFAULT_OGL_ES "libGLESv1_CM.dylib" //???
75 
76 #else
77 /* Desktop Linux */
78 #define DEFAULT_OGL "libGL.so.1"
79 #define DEFAULT_EGL "libEGL.so.1"
80 #define DEFAULT_OGL_ES2 "libGLESv2.so.2"
81 #define DEFAULT_OGL_ES_PVR "libGLES_CM.so.1"
82 #define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
83 #endif /* SDL_VIDEO_DRIVER_RPI */
84 
85 #ifdef SDL_VIDEO_STATIC_ANGLE
86 #define LOAD_FUNC(NAME) \
87 _this->egl_data->NAME = (void *)NAME;
88 #else
89 #define LOAD_FUNC(NAME) \
90 _this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
91 if (!_this->egl_data->NAME) \
92 { \
93  return SDL_SetError("Could not retrieve EGL function " #NAME); \
94 }
95 #endif
96 
97 static const char * SDL_EGL_GetErrorName(EGLint eglErrorCode)
98 {
99 #define SDL_EGL_ERROR_TRANSLATE(e) case e: return #e;
100  switch (eglErrorCode) {
101  SDL_EGL_ERROR_TRANSLATE(EGL_SUCCESS);
102  SDL_EGL_ERROR_TRANSLATE(EGL_NOT_INITIALIZED);
103  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_ACCESS);
104  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_ALLOC);
105  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_ATTRIBUTE);
106  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_CONTEXT);
107  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_CONFIG);
108  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_CURRENT_SURFACE);
109  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_DISPLAY);
110  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_SURFACE);
111  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_MATCH);
112  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_PARAMETER);
113  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_NATIVE_PIXMAP);
114  SDL_EGL_ERROR_TRANSLATE(EGL_BAD_NATIVE_WINDOW);
115  SDL_EGL_ERROR_TRANSLATE(EGL_CONTEXT_LOST);
116  }
117  return "";
118 }
119 
120 int SDL_EGL_SetErrorEx(const char * message, const char * eglFunctionName, EGLint eglErrorCode)
121 {
122  const char * errorText = SDL_EGL_GetErrorName(eglErrorCode);
123  char altErrorText[32];
124  if (errorText[0] == '\0') {
125  /* An unknown-to-SDL error code was reported. Report its hexadecimal value, instead of its name. */
126  SDL_snprintf(altErrorText, SDL_arraysize(altErrorText), "0x%x", (unsigned int)eglErrorCode);
127  errorText = altErrorText;
128  }
129  return SDL_SetError("%s (call to %s failed, reporting an error of %s)", message, eglFunctionName, errorText);
130 }
131 
132 /* EGL implementation of SDL OpenGL ES support */
133 typedef enum {
134  SDL_EGL_DISPLAY_EXTENSION,
135  SDL_EGL_CLIENT_EXTENSION
136 } SDL_EGL_ExtensionType;
137 
138 static SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext)
139 {
140  size_t ext_len;
141  const char *ext_override;
142  const char *egl_extstr;
143  const char *ext_start;
144 
145  /* Invalid extensions can be rejected early */
146  if (ext == NULL || *ext == 0 || SDL_strchr(ext, ' ') != NULL) {
147  /* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid EGL extension"); */
148  return SDL_FALSE;
149  }
150 
151  /* Extensions can be masked with an environment variable.
152  * Unlike the OpenGL override, this will use the set bits of an integer
153  * to disable the extension.
154  * Bit Action
155  * 0 If set, the display extension is masked and not present to SDL.
156  * 1 If set, the client extension is masked and not present to SDL.
157  */
158  ext_override = SDL_getenv(ext);
159  if (ext_override != NULL) {
160  int disable_ext = SDL_atoi(ext_override);
161  if (disable_ext & 0x01 && type == SDL_EGL_DISPLAY_EXTENSION) {
162  return SDL_FALSE;
163  } else if (disable_ext & 0x02 && type == SDL_EGL_CLIENT_EXTENSION) {
164  return SDL_FALSE;
165  }
166  }
167 
168  ext_len = SDL_strlen(ext);
169  switch (type) {
170  case SDL_EGL_DISPLAY_EXTENSION:
171  egl_extstr = _this->egl_data->eglQueryString(_this->egl_data->egl_display, EGL_EXTENSIONS);
172  break;
173  case SDL_EGL_CLIENT_EXTENSION:
174  /* EGL_EXT_client_extensions modifies eglQueryString to return client extensions
175  * if EGL_NO_DISPLAY is passed. Implementations without it are required to return NULL.
176  * This behavior is included in EGL 1.5.
177  */
178  egl_extstr = _this->egl_data->eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
179  break;
180  default:
181  /* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid extension type"); */
182  return SDL_FALSE;
183  }
184 
185  if (egl_extstr != NULL) {
186  ext_start = egl_extstr;
187 
188  while (*ext_start) {
189  ext_start = SDL_strstr(ext_start, ext);
190  if (ext_start == NULL) {
191  return SDL_FALSE;
192  }
193  /* Check if the match is not just a substring of one of the extensions */
194  if (ext_start == egl_extstr || *(ext_start - 1) == ' ') {
195  if (ext_start[ext_len] == ' ' || ext_start[ext_len] == 0) {
196  return SDL_TRUE;
197  }
198  }
199  /* If the search stopped in the middle of an extension, skip to the end of it */
200  ext_start += ext_len;
201  while (*ext_start != ' ' && *ext_start != 0) {
202  ext_start++;
203  }
204  }
205  }
206 
207  return SDL_FALSE;
208 }
209 
210 void *
211 SDL_EGL_GetProcAddress(_THIS, const char *proc)
212 {
213  static char procname[1024];
214  void *retval;
215 
216  /* eglGetProcAddress is busted on Android http://code.google.com/p/android/issues/detail?id=7681 */
217 #if !defined(SDL_VIDEO_DRIVER_ANDROID)
218  if (_this->egl_data->eglGetProcAddress) {
219  retval = _this->egl_data->eglGetProcAddress(proc);
220  if (retval) {
221  return retval;
222  }
223  }
224 #endif
225 
226  retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, proc);
227  if (!retval && SDL_strlen(proc) <= 1022) {
228  procname[0] = '_';
229  SDL_strlcpy(procname + 1, proc, 1022);
230  retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, procname);
231  }
232  return retval;
233 }
234 
235 void
236 SDL_EGL_UnloadLibrary(_THIS)
237 {
238  if (_this->egl_data) {
239  if (_this->egl_data->egl_display) {
240  _this->egl_data->eglTerminate(_this->egl_data->egl_display);
241  _this->egl_data->egl_display = NULL;
242  }
243 
244  if (_this->egl_data->dll_handle) {
245  SDL_UnloadObject(_this->egl_data->dll_handle);
246  _this->egl_data->dll_handle = NULL;
247  }
248  if (_this->egl_data->egl_dll_handle) {
249  SDL_UnloadObject(_this->egl_data->egl_dll_handle);
250  _this->egl_data->egl_dll_handle = NULL;
251  }
252 
253  SDL_free(_this->egl_data);
254  _this->egl_data = NULL;
255  }
256 }
257 
258 int
259 SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_display, EGLenum platform)
260 {
261  void *dll_handle = NULL, *egl_dll_handle = NULL; /* The naming is counter intuitive, but hey, I just work here -- Gabriel */
262  const char *path = NULL;
263  int egl_version_major = 0, egl_version_minor = 0;
264 #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
265  const char *d3dcompiler;
266 #endif
267 #if SDL_VIDEO_DRIVER_RPI
268  SDL_bool vc4 = (0 == access("/sys/module/vc4/", F_OK));
269 #endif
270 
271  if (_this->egl_data) {
272  return SDL_SetError("EGL context already created");
273  }
274 
275  _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData));
276  if (!_this->egl_data) {
277  return SDL_OutOfMemory();
278  }
279 
280 #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
282  if (d3dcompiler) {
283  if (SDL_strcasecmp(d3dcompiler, "none") != 0) {
284  if (SDL_LoadObject(d3dcompiler) == NULL) {
285  SDL_ClearError();
286  }
287  }
288  } else {
290  /* Try the newer d3d compilers first */
291  const char *d3dcompiler_list[] = {
292  "d3dcompiler_47.dll", "d3dcompiler_46.dll",
293  };
294  int i;
295 
296  for (i = 0; i < SDL_arraysize(d3dcompiler_list); ++i) {
297  if (SDL_LoadObject(d3dcompiler_list[i]) != NULL) {
298  break;
299  }
300  SDL_ClearError();
301  }
302  } else {
303  if (SDL_LoadObject("d3dcompiler_43.dll") == NULL) {
304  SDL_ClearError();
305  }
306  }
307  }
308 #endif
309 
310 #ifndef SDL_VIDEO_STATIC_ANGLE
311  /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */
312  path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
313  if (path != NULL) {
314  egl_dll_handle = SDL_LoadObject(path);
315  }
316 
317  if (egl_dll_handle == NULL) {
319  if (_this->gl_config.major_version > 1) {
320  path = DEFAULT_OGL_ES2;
321  egl_dll_handle = SDL_LoadObject(path);
322 #ifdef ALT_OGL_ES2
323  if (egl_dll_handle == NULL && !vc4) {
324  path = ALT_OGL_ES2;
325  egl_dll_handle = SDL_LoadObject(path);
326  }
327 #endif
328 
329  } else {
330  path = DEFAULT_OGL_ES;
331  egl_dll_handle = SDL_LoadObject(path);
332  if (egl_dll_handle == NULL) {
333  path = DEFAULT_OGL_ES_PVR;
334  egl_dll_handle = SDL_LoadObject(path);
335  }
336 #ifdef ALT_OGL_ES2
337  if (egl_dll_handle == NULL && !vc4) {
338  path = ALT_OGL_ES2;
339  egl_dll_handle = SDL_LoadObject(path);
340  }
341 #endif
342  }
343  }
344 #ifdef DEFAULT_OGL
345  else {
346  path = DEFAULT_OGL;
347  egl_dll_handle = SDL_LoadObject(path);
348  }
349 #endif
350  }
351  _this->egl_data->egl_dll_handle = egl_dll_handle;
352 
353  if (egl_dll_handle == NULL) {
354  return SDL_SetError("Could not initialize OpenGL / GLES library");
355  }
356 
357  /* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */
358  if (egl_path != NULL) {
359  dll_handle = SDL_LoadObject(egl_path);
360  }
361  /* Try loading a EGL symbol, if it does not work try the default library paths */
362  if (dll_handle == NULL || SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
363  if (dll_handle != NULL) {
364  SDL_UnloadObject(dll_handle);
365  }
366  path = SDL_getenv("SDL_VIDEO_EGL_DRIVER");
367  if (path == NULL) {
368  path = DEFAULT_EGL;
369  }
370  dll_handle = SDL_LoadObject(path);
371 
372 #ifdef ALT_EGL
373  if (dll_handle == NULL && !vc4) {
374  path = ALT_EGL;
375  dll_handle = SDL_LoadObject(path);
376  }
377 #endif
378 
379  if (dll_handle == NULL || SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
380  if (dll_handle != NULL) {
381  SDL_UnloadObject(dll_handle);
382  }
383  return SDL_SetError("Could not load EGL library");
384  }
385  SDL_ClearError();
386  }
387 #endif
388 
389  _this->egl_data->dll_handle = dll_handle;
390 
391  /* Load new function pointers */
392  LOAD_FUNC(eglGetDisplay);
393  LOAD_FUNC(eglInitialize);
394  LOAD_FUNC(eglTerminate);
395  LOAD_FUNC(eglGetProcAddress);
396  LOAD_FUNC(eglChooseConfig);
397  LOAD_FUNC(eglGetConfigAttrib);
398  LOAD_FUNC(eglCreateContext);
399  LOAD_FUNC(eglDestroyContext);
400  LOAD_FUNC(eglCreatePbufferSurface);
401  LOAD_FUNC(eglCreateWindowSurface);
402  LOAD_FUNC(eglDestroySurface);
403  LOAD_FUNC(eglMakeCurrent);
404  LOAD_FUNC(eglSwapBuffers);
405  LOAD_FUNC(eglSwapInterval);
406  LOAD_FUNC(eglWaitNative);
407  LOAD_FUNC(eglWaitGL);
408  LOAD_FUNC(eglBindAPI);
409  LOAD_FUNC(eglQueryString);
410  LOAD_FUNC(eglGetError);
411 
412  if (_this->egl_data->eglQueryString) {
413  /* EGL 1.5 allows querying for client version */
414  const char *egl_version = _this->egl_data->eglQueryString(EGL_NO_DISPLAY, EGL_VERSION);
415  if (egl_version != NULL) {
416  if (SDL_sscanf(egl_version, "%d.%d", &egl_version_major, &egl_version_minor) != 2) {
417  egl_version_major = 0;
418  egl_version_minor = 0;
419  SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not parse EGL version string: %s", egl_version);
420  }
421  }
422  }
423 
424  _this->egl_data->egl_version_major = egl_version_major;
425  _this->egl_data->egl_version_minor = egl_version_minor;
426 
427  if (egl_version_major == 1 && egl_version_minor == 5) {
428  LOAD_FUNC(eglGetPlatformDisplay);
429  }
430 
431  _this->egl_data->egl_display = EGL_NO_DISPLAY;
432 #if !defined(__WINRT__)
433  if (platform) {
434  if (egl_version_major == 1 && egl_version_minor == 5) {
435  _this->egl_data->egl_display = _this->egl_data->eglGetPlatformDisplay(platform, (void *)(size_t)native_display, NULL);
436  } else {
437  if (SDL_EGL_HasExtension(_this, SDL_EGL_CLIENT_EXTENSION, "EGL_EXT_platform_base")) {
438  _this->egl_data->eglGetPlatformDisplayEXT = SDL_EGL_GetProcAddress(_this, "eglGetPlatformDisplayEXT");
439  if (_this->egl_data->eglGetPlatformDisplayEXT) {
440  _this->egl_data->egl_display = _this->egl_data->eglGetPlatformDisplayEXT(platform, (void *)(size_t)native_display, NULL);
441  }
442  }
443  }
444  }
445  /* Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails */
446  if (_this->egl_data->egl_display == EGL_NO_DISPLAY) {
447  _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display);
448  }
449  if (_this->egl_data->egl_display == EGL_NO_DISPLAY) {
450  return SDL_SetError("Could not get EGL display");
451  }
452 
453  if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
454  return SDL_SetError("Could not initialize EGL");
455  }
456 #endif
457 
458  if (path) {
460  } else {
461  *_this->gl_config.driver_path = '\0';
462  }
463 
464  return 0;
465 }
466 
467 void
468 SDL_EGL_SetRequiredVisualId(_THIS, int visual_id)
469 {
470  _this->egl_data->egl_required_visual_id=visual_id;
471 }
472 
473 #ifdef DUMP_EGL_CONFIG
474 
475 #define ATTRIBUTE(_attr) { _attr, #_attr }
476 
477 typedef struct {
479  char const* name;
480 } Attribute;
481 
482 Attribute attributes[] = {
483  ATTRIBUTE( EGL_BUFFER_SIZE ),
484  ATTRIBUTE( EGL_ALPHA_SIZE ),
485  ATTRIBUTE( EGL_BLUE_SIZE ),
486  ATTRIBUTE( EGL_GREEN_SIZE ),
487  ATTRIBUTE( EGL_RED_SIZE ),
488  ATTRIBUTE( EGL_DEPTH_SIZE ),
489  ATTRIBUTE( EGL_STENCIL_SIZE ),
490  ATTRIBUTE( EGL_CONFIG_CAVEAT ),
491  ATTRIBUTE( EGL_CONFIG_ID ),
492  ATTRIBUTE( EGL_LEVEL ),
493  ATTRIBUTE( EGL_MAX_PBUFFER_HEIGHT ),
494  ATTRIBUTE( EGL_MAX_PBUFFER_WIDTH ),
495  ATTRIBUTE( EGL_MAX_PBUFFER_PIXELS ),
496  ATTRIBUTE( EGL_NATIVE_RENDERABLE ),
497  ATTRIBUTE( EGL_NATIVE_VISUAL_ID ),
498  ATTRIBUTE( EGL_NATIVE_VISUAL_TYPE ),
499  ATTRIBUTE( EGL_SAMPLES ),
500  ATTRIBUTE( EGL_SAMPLE_BUFFERS ),
501  ATTRIBUTE( EGL_SURFACE_TYPE ),
502  ATTRIBUTE( EGL_TRANSPARENT_TYPE ),
503  ATTRIBUTE( EGL_TRANSPARENT_BLUE_VALUE ),
504  ATTRIBUTE( EGL_TRANSPARENT_GREEN_VALUE ),
505  ATTRIBUTE( EGL_TRANSPARENT_RED_VALUE ),
506  ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGB ),
507  ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGBA ),
508  ATTRIBUTE( EGL_MIN_SWAP_INTERVAL ),
509  ATTRIBUTE( EGL_MAX_SWAP_INTERVAL ),
510  ATTRIBUTE( EGL_LUMINANCE_SIZE ),
511  ATTRIBUTE( EGL_ALPHA_MASK_SIZE ),
512  ATTRIBUTE( EGL_COLOR_BUFFER_TYPE ),
513  ATTRIBUTE( EGL_RENDERABLE_TYPE ),
514  ATTRIBUTE( EGL_MATCH_NATIVE_PIXMAP ),
515  ATTRIBUTE( EGL_CONFORMANT ),
516 };
517 
518 
519 static void dumpconfig(_THIS, EGLConfig config)
520 {
521  int attr;
522  for (attr = 0 ; attr<sizeof(attributes)/sizeof(Attribute) ; attr++) {
523  EGLint value;
524  _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, attributes[attr].attribute, &value);
525  SDL_Log("\t%-32s: %10d (0x%08x)\n", attributes[attr].name, value, value);
526  }
527 }
528 
529 #endif /* DUMP_EGL_CONFIG */
530 
531 int
532 SDL_EGL_ChooseConfig(_THIS)
533 {
534 /* 64 seems nice. */
535  EGLint attribs[64];
536  EGLint found_configs = 0, value;
537  /* 128 seems even nicer here */
538  EGLConfig configs[128];
539  int i, j, best_bitdiff = -1, bitdiff;
540 
541  if (!_this->egl_data) {
542  /* The EGL library wasn't loaded, SDL_GetError() should have info */
543  return -1;
544  }
545 
546  /* Get a valid EGL configuration */
547  i = 0;
548  attribs[i++] = EGL_RED_SIZE;
550  attribs[i++] = EGL_GREEN_SIZE;
552  attribs[i++] = EGL_BLUE_SIZE;
554 
555  if (_this->gl_config.alpha_size) {
556  attribs[i++] = EGL_ALPHA_SIZE;
558  }
559 
560  if (_this->gl_config.buffer_size) {
563  }
564 
565  attribs[i++] = EGL_DEPTH_SIZE;
567 
571  }
572 
576  }
577 
579  attribs[i++] = EGL_SAMPLES;
581  }
582 
585 #ifdef EGL_KHR_create_context
586  if (_this->gl_config.major_version >= 3 &&
587  SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context")) {
589  } else
590 #endif
591  if (_this->gl_config.major_version >= 2) {
593  } else {
595  }
596  _this->egl_data->eglBindAPI(EGL_OPENGL_ES_API);
597  } else {
598  attribs[i++] = EGL_OPENGL_BIT;
599  _this->egl_data->eglBindAPI(EGL_OPENGL_API);
600  }
601 
602  if (_this->egl_data->egl_surfacetype) {
604  attribs[i++] = _this->egl_data->egl_surfacetype;
605  }
606 
607  attribs[i++] = EGL_NONE;
608 
609  if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display,
610  attribs,
611  configs, SDL_arraysize(configs),
612  &found_configs) == EGL_FALSE ||
613  found_configs == 0) {
614  return SDL_EGL_SetError("Couldn't find matching EGL config", "eglChooseConfig");
615  }
616 
617  /* eglChooseConfig returns a number of configurations that match or exceed the requested attribs. */
618  /* From those, we select the one that matches our requirements more closely via a makeshift algorithm */
619 
620  for (i = 0; i < found_configs; i++ ) {
621  if (_this->egl_data->egl_required_visual_id)
622  {
623  EGLint format;
624  _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
625  configs[i],
627  if (_this->egl_data->egl_required_visual_id != format)
628  continue;
629  }
630 
631  bitdiff = 0;
632  for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) {
633  if (attribs[j] == EGL_NONE) {
634  break;
635  }
636 
637  if ( attribs[j+1] != EGL_DONT_CARE && (
638  attribs[j] == EGL_RED_SIZE ||
639  attribs[j] == EGL_GREEN_SIZE ||
640  attribs[j] == EGL_BLUE_SIZE ||
641  attribs[j] == EGL_ALPHA_SIZE ||
642  attribs[j] == EGL_DEPTH_SIZE ||
643  attribs[j] == EGL_STENCIL_SIZE)) {
644  _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], attribs[j], &value);
645  bitdiff += value - attribs[j + 1]; /* value is always >= attrib */
646  }
647  }
648 
649  if (bitdiff < best_bitdiff || best_bitdiff == -1) {
650  _this->egl_data->egl_config = configs[i];
651 
652  best_bitdiff = bitdiff;
653  }
654 
655  if (bitdiff == 0) {
656  break; /* we found an exact match! */
657  }
658  }
659 
660 #ifdef DUMP_EGL_CONFIG
661  dumpconfig(_this, _this->egl_data->egl_config);
662 #endif
663 
664  return 0;
665 }
666 
668 SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
669 {
670  /* max 14 values plus terminator. */
671  EGLint attribs[15];
672  int attr = 0;
673 
674  EGLContext egl_context, share_context = EGL_NO_CONTEXT;
675  EGLint profile_mask = _this->gl_config.profile_mask;
676  EGLint major_version = _this->gl_config.major_version;
677  EGLint minor_version = _this->gl_config.minor_version;
678  SDL_bool profile_es = (profile_mask == SDL_GL_CONTEXT_PROFILE_ES);
679 
680  if (!_this->egl_data) {
681  /* The EGL library wasn't loaded, SDL_GetError() should have info */
682  return NULL;
683  }
684 
686  share_context = (EGLContext)SDL_GL_GetCurrentContext();
687  }
688 
689 #if SDL_VIDEO_DRIVER_ANDROID
691  /* If SDL_GL_CONTEXT_DEBUG_FLAG is set but EGL_KHR_debug unsupported, unset.
692  * This is required because some Android devices like to complain about it
693  * by "silently" failing, logging a hint which could be easily overlooked:
694  * E/libEGL (26984): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
695  * The following explicitly checks for EGL_KHR_debug before EGL 1.5
696  */
697  int egl_version_major = _this->egl_data->egl_version_major;
698  int egl_version_minor = _this->egl_data->egl_version_minor;
699  if (((egl_version_major < 1) || (egl_version_major == 1 && egl_version_minor < 5)) &&
700  !SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_debug")) {
701  /* SDL profile bits match EGL profile bits. */
703  }
704  }
705 #endif
706 
707  /* Set the context version and other attributes. */
708  if ((major_version < 3 || (minor_version == 0 && profile_es)) &&
709  _this->gl_config.flags == 0 &&
710  (profile_mask == 0 || profile_es)) {
711  /* Create a context without using EGL_KHR_create_context attribs.
712  * When creating a GLES context without EGL_KHR_create_context we can
713  * only specify the major version. When creating a desktop GL context
714  * we can't specify any version, so we only try in that case when the
715  * version is less than 3.0 (matches SDL's GLX/WGL behavior.)
716  */
717  if (profile_es) {
719  attribs[attr++] = SDL_max(major_version, 1);
720  }
721  } else {
722 #ifdef EGL_KHR_create_context
723  /* The Major/minor version, context profiles, and context flags can
724  * only be specified when this extension is available.
725  */
726  if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context")) {
728  attribs[attr++] = major_version;
730  attribs[attr++] = minor_version;
731 
732  /* SDL profile bits match EGL profile bits. */
733  if (profile_mask != 0 && profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
735  attribs[attr++] = profile_mask;
736  }
737 
738  /* SDL flags match EGL flags. */
739  if (_this->gl_config.flags != 0) {
740  attribs[attr++] = EGL_CONTEXT_FLAGS_KHR;
741  attribs[attr++] = _this->gl_config.flags;
742  }
743  } else
744 #endif /* EGL_KHR_create_context */
745  {
746  SDL_SetError("Could not create EGL context (context attributes are not supported)");
747  return NULL;
748  }
749  }
750 
751  if (_this->gl_config.no_error) {
752 #ifdef EGL_KHR_create_context_no_error
753  if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context_no_error")) {
755  attribs[attr++] = _this->gl_config.no_error;
756  } else
757 #endif
758  {
759  SDL_SetError("EGL implementation does not support no_error contexts");
760  return NULL;
761  }
762  }
763 
764  attribs[attr++] = EGL_NONE;
765 
766  /* Bind the API */
767  if (profile_es) {
768  _this->egl_data->eglBindAPI(EGL_OPENGL_ES_API);
769  } else {
770  _this->egl_data->eglBindAPI(EGL_OPENGL_API);
771  }
772 
773  egl_context = _this->egl_data->eglCreateContext(_this->egl_data->egl_display,
774  _this->egl_data->egl_config,
775  share_context, attribs);
776 
777  if (egl_context == EGL_NO_CONTEXT) {
778  SDL_EGL_SetError("Could not create EGL context", "eglCreateContext");
779  return NULL;
780  }
781 
782  _this->egl_data->egl_swapinterval = 0;
783 
784  if (SDL_EGL_MakeCurrent(_this, egl_surface, egl_context) < 0) {
785  /* Save the SDL error set by SDL_EGL_MakeCurrent */
786  char errorText[1024];
787  SDL_strlcpy(errorText, SDL_GetError(), SDL_arraysize(errorText));
788 
789  /* Delete the context, which may alter the value returned by SDL_GetError() */
790  SDL_EGL_DeleteContext(_this, egl_context);
791 
792  /* Restore the SDL error */
793  SDL_SetError("%s", errorText);
794 
795  return NULL;
796  }
797 
798  return (SDL_GLContext) egl_context;
799 }
800 
801 int
802 SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
803 {
804  EGLContext egl_context = (EGLContext) context;
805 
806  if (!_this->egl_data) {
807  return SDL_SetError("OpenGL not initialized");
808  }
809 
810  /* The android emulator crashes badly if you try to eglMakeCurrent
811  * with a valid context and invalid surface, so we have to check for both here.
812  */
813  if (!egl_context || !egl_surface) {
814  _this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
815  } else {
816  if (!_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display,
817  egl_surface, egl_surface, egl_context)) {
818  return SDL_EGL_SetError("Unable to make EGL context current", "eglMakeCurrent");
819  }
820  }
821 
822  return 0;
823 }
824 
825 int
826 SDL_EGL_SetSwapInterval(_THIS, int interval)
827 {
828  EGLBoolean status;
829 
830  if (!_this->egl_data) {
831  return SDL_SetError("EGL not initialized");
832  }
833 
834  status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval);
835  if (status == EGL_TRUE) {
836  _this->egl_data->egl_swapinterval = interval;
837  return 0;
838  }
839 
840  return SDL_EGL_SetError("Unable to set the EGL swap interval", "eglSwapInterval");
841 }
842 
843 int
844 SDL_EGL_GetSwapInterval(_THIS)
845 {
846  if (!_this->egl_data) {
847  SDL_SetError("EGL not initialized");
848  return 0;
849  }
850 
851  return _this->egl_data->egl_swapinterval;
852 }
853 
854 int
855 SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface)
856 {
857  if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, egl_surface)) {
858  return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers");
859  }
860  return 0;
861 }
862 
863 void
864 SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
865 {
866  EGLContext egl_context = (EGLContext) context;
867 
868  /* Clean up GLES and EGL */
869  if (!_this->egl_data) {
870  return;
871  }
872 
873  if (egl_context != NULL && egl_context != EGL_NO_CONTEXT) {
874  _this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context);
875  }
876 
877 }
878 
879 EGLSurface *
880 SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
881 {
882  /* max 2 values plus terminator. */
883  EGLint attribs[3];
884  int attr = 0;
885 
887 
888  if (SDL_EGL_ChooseConfig(_this) != 0) {
889  return EGL_NO_SURFACE;
890  }
891 
892 #if SDL_VIDEO_DRIVER_ANDROID
893  {
894  /* Android docs recommend doing this!
895  * Ref: http://developer.android.com/reference/android/app/NativeActivity.html
896  */
897  EGLint format;
898  _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
899  _this->egl_data->egl_config,
901 
902  ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
903 
904  /* Update SurfaceView holder format.
905  * May triggers a sequence surfaceDestroyed(), surfaceCreated(), surfaceChanged(). */
907  }
908 #endif
910 #ifdef EGL_KHR_gl_colorspace
911  if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
912  attribs[attr++] = EGL_GL_COLORSPACE_KHR;
914  } else
915 #endif
916  {
917  SDL_SetError("EGL implementation does not support sRGB system framebuffers");
918  return EGL_NO_SURFACE;
919  }
920  }
921 
922  attribs[attr++] = EGL_NONE;
923 
924  surface = _this->egl_data->eglCreateWindowSurface(
925  _this->egl_data->egl_display,
926  _this->egl_data->egl_config,
927  nw, &attribs[0]);
928  if (surface == EGL_NO_SURFACE) {
929  SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
930  }
931  return surface;
932 }
933 
934 void
935 SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface)
936 {
937  if (!_this->egl_data) {
938  return;
939  }
940 
941  if (egl_surface != EGL_NO_SURFACE) {
942  _this->egl_data->eglDestroySurface(_this->egl_data->egl_display, egl_surface);
943  }
944 }
945 
946 #endif /* SDL_VIDEO_OPENGL_EGL */
947 
948 /* vi: set ts=4 sw=4 expandtab: */
949 
EGL_CONFORMANT
#define EGL_CONFORMANT
Definition: egl.h:211
EGL_NATIVE_VISUAL_TYPE
#define EGL_NATIVE_VISUAL_TYPE
Definition: egl.h:94
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
eglGetDisplay
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id)
EGL_OPENGL_ES_BIT
#define EGL_OPENGL_ES_BIT
Definition: egl.h:189
SDL_GetError
#define SDL_GetError
Definition: SDL_dynapi_overrides.h:113
EGLContext
void * EGLContext
Definition: egl.h:60
SDL_strlcpy
#define SDL_strlcpy
Definition: SDL_dynapi_overrides.h:394
EGL_MAX_PBUFFER_WIDTH
#define EGL_MAX_PBUFFER_WIDTH
Definition: egl.h:91
WIN_IsWindowsVistaOrGreater
BOOL WIN_IsWindowsVistaOrGreater(void)
eglMakeCurrent
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
SDL_ClearError
#define SDL_ClearError
Definition: SDL_dynapi_overrides.h:114
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR
Definition: eglext.h:92
eglSwapBuffers
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
EGL_OPENGL_ES2_BIT
#define EGL_OPENGL_ES2_BIT
Definition: egl.h:214
eglInitialize
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
eglWaitNative
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine)
NULL
#define NULL
Definition: begin_code.h:167
surface
EGLSurface surface
Definition: eglext.h:248
SDL_VideoDevice::buffer_size
int buffer_size
Definition: SDL_sysvideo.h:332
attribs
const GLint * attribs
Definition: SDL_opengl_glext.h:9688
SDL_VideoDevice::multisamplesamples
int multisamplesamples
Definition: SDL_sysvideo.h:341
message
GLuint GLsizei const GLchar * message
Definition: SDL_opengl_glext.h:2483
SDL_VideoDevice::blue_size
int blue_size
Definition: SDL_sysvideo.h:329
access
GLuint GLint GLboolean GLint GLenum access
Definition: SDL_opengl_glext.h:2162
EGL_BAD_MATCH
#define EGL_BAD_MATCH
Definition: egl.h:70
NativeWindowType
EGLNativeWindowType NativeWindowType
Definition: eglplatform.h:112
SDL_log.h
EGL_CONFIG_CAVEAT
#define EGL_CONFIG_CAVEAT
Definition: egl.h:77
eglDestroySurface
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
EGL_OPENGL_API
#define EGL_OPENGL_API
Definition: egl.h:232
EGL_MIN_SWAP_INTERVAL
#define EGL_MIN_SWAP_INTERVAL
Definition: egl.h:153
SDL_VideoDevice::driver_path
char driver_path[256]
Definition: SDL_sysvideo.h:354
SDL_VideoDevice::major_version
int major_version
Definition: SDL_sysvideo.h:343
EGLenum
unsigned int EGLenum
Definition: egl.h:171
EGL_SURFACE_TYPE
#define EGL_SURFACE_TYPE
Definition: egl.h:110
Android_JNI_SetSurfaceViewFormat
void Android_JNI_SetSurfaceViewFormat(int format)
EGL_BAD_PARAMETER
#define EGL_BAD_PARAMETER
Definition: egl.h:73
EGL_RENDERABLE_TYPE
#define EGL_RENDERABLE_TYPE
Definition: egl.h:195
SDL_UnloadObject
#define SDL_UnloadObject
Definition: SDL_dynapi_overrides.h:234
SDL_VideoDevice::profile_mask
int profile_mask
Definition: SDL_sysvideo.h:346
EGL_OPENGL_BIT
#define EGL_OPENGL_BIT
Definition: egl.h:233
path
GLsizei const GLchar *const * path
Definition: SDL_opengl_glext.h:3730
SDL_VideoDevice::depth_size
int depth_size
Definition: SDL_sysvideo.h:331
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
EGL_TRUE
#define EGL_TRUE
Definition: egl.h:116
EGL_GL_COLORSPACE_KHR
#define EGL_GL_COLORSPACE_KHR
Definition: eglext.h:171
EGL_NATIVE_VISUAL_ID
#define EGL_NATIVE_VISUAL_ID
Definition: egl.h:93
eglGetPlatformDisplay
EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay(EGLenum platform, void *native_display, const EGLAttrib *attrib_list)
eglGetProcAddress
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname)
SDL_LoadObject
#define SDL_LoadObject
Definition: SDL_dynapi_overrides.h:232
EGL_TRANSPARENT_BLUE_VALUE
#define EGL_TRANSPARENT_BLUE_VALUE
Definition: egl.h:111
SDL_VideoDevice::red_size
int red_size
Definition: SDL_sysvideo.h:327
EGL_NO_CONTEXT
#define EGL_NO_CONTEXT
Definition: egl.h:98
EGL_BAD_ALLOC
#define EGL_BAD_ALLOC
Definition: egl.h:64
EGL_GREEN_SIZE
#define EGL_GREEN_SIZE
Definition: egl.h:85
SDL_HINT_VIDEO_WIN_D3DCOMPILER
#define SDL_HINT_VIDEO_WIN_D3DCOMPILER
A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries.
Definition: SDL_hints.h:676
SDL_strcasecmp
#define SDL_strcasecmp
Definition: SDL_dynapi_overrides.h:419
eglBindAPI
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api)
SDL_egl_c.h
EGL_MAX_PBUFFER_PIXELS
#define EGL_MAX_PBUFFER_PIXELS
Definition: egl.h:90
EGL_NATIVE_RENDERABLE
#define EGL_NATIVE_RENDERABLE
Definition: egl.h:92
EGL_OPENGL_ES3_BIT_KHR
#define EGL_OPENGL_ES3_BIT_KHR
Definition: eglext.h:101
SDL_GL_CONTEXT_DEBUG_FLAG
@ SDL_GL_CONTEXT_DEBUG_FLAG
Definition: SDL_video.h:238
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
EGL_NO_DISPLAY
#define EGL_NO_DISPLAY
Definition: egl.h:99
EGL_MAX_SWAP_INTERVAL
#define EGL_MAX_SWAP_INTERVAL
Definition: egl.h:154
context
static screen_context_t context
Definition: video.c:25
SDL_strchr
#define SDL_strchr
Definition: SDL_dynapi_overrides.h:401
EGL_NOT_INITIALIZED
#define EGL_NOT_INITIALIZED
Definition: egl.h:97
EGL_BLUE_SIZE
#define EGL_BLUE_SIZE
Definition: egl.h:75
eglChooseConfig
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
NativeDisplayType
EGLNativeDisplayType NativeDisplayType
Definition: eglplatform.h:110
EGL_TRANSPARENT_TYPE
#define EGL_TRANSPARENT_TYPE
Definition: egl.h:115
retval
SDL_bool retval
Definition: testgamecontroller.c:65
EGLConfig
void * EGLConfig
Definition: egl.h:58
EGL_ALPHA_MASK_SIZE
#define EGL_ALPHA_MASK_SIZE
Definition: egl.h:176
SDL_Log
#define SDL_Log
Definition: SDL_dynapi_overrides.h:31
EGL_NO_SURFACE
#define EGL_NO_SURFACE
Definition: egl.h:100
EGL_SUCCESS
#define EGL_SUCCESS
Definition: egl.h:109
EGL_RED_SIZE
#define EGL_RED_SIZE
Definition: egl.h:104
EGL_OPENGL_ES_API
#define EGL_OPENGL_ES_API
Definition: egl.h:191
EGL_EXTENSIONS
#define EGL_EXTENSIONS
Definition: egl.h:83
EGL_GL_COLORSPACE_SRGB_KHR
#define EGL_GL_COLORSPACE_SRGB_KHR
Definition: eglext.h:172
config
EGLConfig config
Definition: eglext.h:433
EGL_VERSION
#define EGL_VERSION
Definition: egl.h:118
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
EGL_BAD_CURRENT_SURFACE
#define EGL_BAD_CURRENT_SURFACE
Definition: egl.h:68
EGL_CONTEXT_OPENGL_NO_ERROR_KHR
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR
Definition: eglext.h:106
SDL_max
#define SDL_max(x, y)
Definition: SDL_stdinc.h:407
EGL_BUFFER_SIZE
#define EGL_BUFFER_SIZE
Definition: egl.h:76
EGL_BAD_NATIVE_WINDOW
#define EGL_BAD_NATIVE_WINDOW
Definition: egl.h:72
EGL_DEPTH_SIZE
#define EGL_DEPTH_SIZE
Definition: egl.h:80
eglDestroyContext
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
EGL_SAMPLE_BUFFERS
#define EGL_SAMPLE_BUFFERS
Definition: egl.h:106
name
GLuint const GLchar * name
Definition: SDL_opengl_glext.h:660
EGL_STENCIL_SIZE
#define EGL_STENCIL_SIZE
Definition: egl.h:108
EGL_BAD_SURFACE
#define EGL_BAD_SURFACE
Definition: egl.h:74
SDL_VideoDevice::multisamplebuffers
int multisamplebuffers
Definition: SDL_sysvideo.h:340
EGL_LUMINANCE_SIZE
#define EGL_LUMINANCE_SIZE
Definition: egl.h:188
SDL_GL_CONTEXT_PROFILE_ES
@ SDL_GL_CONTEXT_PROFILE_ES
Definition: SDL_video.h:233
SDL_VideoDevice::share_with_current_context
int share_with_current_context
Definition: SDL_sysvideo.h:347
SDL_LOG_CATEGORY_VIDEO
@ SDL_LOG_CATEGORY_VIDEO
Definition: SDL_log.h:71
EGL_LEVEL
#define EGL_LEVEL
Definition: egl.h:88
SDL_VideoDevice::green_size
int green_size
Definition: SDL_sysvideo.h:328
eglCreateContext
EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
EGL_TRANSPARENT_RED_VALUE
#define EGL_TRANSPARENT_RED_VALUE
Definition: egl.h:113
EGL_BAD_ATTRIBUTE
#define EGL_BAD_ATTRIBUTE
Definition: egl.h:65
EGL_ALPHA_SIZE
#define EGL_ALPHA_SIZE
Definition: egl.h:62
eglGetError
EGLAPI EGLint EGLAPIENTRY eglGetError(void)
SDL_VideoDevice::no_error
int no_error
Definition: SDL_sysvideo.h:351
eglCreateWindowSurface
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
EGL_SAMPLES
#define EGL_SAMPLES
Definition: egl.h:105
EGL_COLOR_BUFFER_TYPE
#define EGL_COLOR_BUFFER_TYPE
Definition: egl.h:183
SDL_VideoDevice::dll_handle
void * dll_handle
Definition: SDL_sysvideo.h:355
SDL_GL_GetCurrentContext
#define SDL_GL_GetCurrentContext
Definition: SDL_dynapi_overrides.h:562
SDL_sscanf
#define SDL_sscanf
Definition: SDL_dynapi_overrides.h:39
EGL_MATCH_NATIVE_PIXMAP
#define EGL_MATCH_NATIVE_PIXMAP
Definition: egl.h:213
EGLBoolean
unsigned int EGLBoolean
Definition: egl.h:54
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_VideoDevice::flags
int flags
Definition: SDL_sysvideo.h:345
EGL_NONE
#define EGL_NONE
Definition: egl.h:95
eglSwapInterval
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval)
EGL_MAX_PBUFFER_HEIGHT
#define EGL_MAX_PBUFFER_HEIGHT
Definition: egl.h:89
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
SDL_atoi
#define SDL_atoi
Definition: SDL_dynapi_overrides.h:410
EGL_TRANSPARENT_GREEN_VALUE
#define EGL_TRANSPARENT_GREEN_VALUE
Definition: egl.h:112
SDL_GLContext
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:193
SDL_getenv
#define SDL_getenv
Definition: SDL_dynapi_overrides.h:378
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
native_display
void * native_display
Definition: eglext.h:789
attribute
EGLSurface EGLint attribute
Definition: eglext.h:263
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
EGLint
khronos_int32_t EGLint
Definition: eglplatform.h:122
EGL_CONTEXT_CLIENT_VERSION
#define EGL_CONTEXT_CLIENT_VERSION
Definition: egl.h:212
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
EGL_BAD_NATIVE_PIXMAP
#define EGL_BAD_NATIVE_PIXMAP
Definition: egl.h:71
SDL_snprintf
#define SDL_snprintf
Definition: SDL_dynapi_overrides.h:40
j
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
SDL_LoadFunction
void * SDL_LoadFunction(void *handle, const char *name)
eglCreatePbufferSurface
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
EGL_CONTEXT_MAJOR_VERSION_KHR
#define EGL_CONTEXT_MAJOR_VERSION_KHR
Definition: eglext.h:89
EGL_CONTEXT_FLAGS_KHR
#define EGL_CONTEXT_FLAGS_KHR
Definition: eglext.h:91
SDL_hints.h
eglTerminate
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy)
EGL_CONTEXT_LOST
#define EGL_CONTEXT_LOST
Definition: egl.h:152
SDL_VideoDevice::framebuffer_srgb_capable
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:350
EGL_BAD_ACCESS
#define EGL_BAD_ACCESS
Definition: egl.h:63
SDL_VideoDevice::alpha_size
int alpha_size
Definition: SDL_sysvideo.h:330
EGL_DONT_CARE
#define EGL_DONT_CARE
Definition: egl.h:81
SDL_strlen
#define SDL_strlen
Definition: SDL_dynapi_overrides.h:393
EGL_BAD_CONFIG
#define EGL_BAD_CONFIG
Definition: egl.h:66
eglWaitGL
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void)
EGLSurface
void * EGLSurface
Definition: egl.h:59
EGL_CONFIG_ID
#define EGL_CONFIG_ID
Definition: egl.h:78
SDL_sysvideo.h
eglQueryString
const EGLAPI char *EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name)
SDL_VideoDevice::stencil_size
int stencil_size
Definition: SDL_sysvideo.h:333
SDL_strstr
#define SDL_strstr
Definition: SDL_dynapi_overrides.h:403
SDL_VideoDevice::minor_version
int minor_version
Definition: SDL_sysvideo.h:344
SDL_LogWarn
#define SDL_LogWarn
Definition: SDL_dynapi_overrides.h:35
EGL_CONTEXT_MINOR_VERSION_KHR
#define EGL_CONTEXT_MINOR_VERSION_KHR
Definition: eglext.h:90
SDL_loadso.h
type
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
EGL_BIND_TO_TEXTURE_RGB
#define EGL_BIND_TO_TEXTURE_RGB
Definition: egl.h:150
EGL_BAD_DISPLAY
#define EGL_BAD_DISPLAY
Definition: egl.h:69
EGL_BIND_TO_TEXTURE_RGBA
#define EGL_BIND_TO_TEXTURE_RGBA
Definition: egl.h:151
EGL_FALSE
#define EGL_FALSE
Definition: egl.h:84
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
eglGetConfigAttrib
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
EGL_BAD_CONTEXT
#define EGL_BAD_CONTEXT
Definition: egl.h:67
SDL_VideoDevice::gl_config
struct SDL_VideoDevice::@261 gl_config