| | |
| | | } |
| | | } |
| | | |
| | | _this->egl_data->egl_version_major = egl_version_major; |
| | | _this->egl_data->egl_version_minor = egl_version_minor; |
| | | |
| | | if (egl_version_major == 1 && egl_version_minor == 5) { |
| | | LOAD_FUNC(eglGetPlatformDisplay); |
| | | } |
| | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | #ifdef DUMP_EGL_CONFIG |
| | | |
| | | #define ATTRIBUTE(_attr) { _attr, #_attr } |
| | | |
| | | typedef struct { |
| | | EGLint attribute; |
| | | char const* name; |
| | | } Attribute; |
| | | |
| | | Attribute attributes[] = { |
| | | ATTRIBUTE( EGL_BUFFER_SIZE ), |
| | | ATTRIBUTE( EGL_ALPHA_SIZE ), |
| | | ATTRIBUTE( EGL_BLUE_SIZE ), |
| | | ATTRIBUTE( EGL_GREEN_SIZE ), |
| | | ATTRIBUTE( EGL_RED_SIZE ), |
| | | ATTRIBUTE( EGL_DEPTH_SIZE ), |
| | | ATTRIBUTE( EGL_STENCIL_SIZE ), |
| | | ATTRIBUTE( EGL_CONFIG_CAVEAT ), |
| | | ATTRIBUTE( EGL_CONFIG_ID ), |
| | | ATTRIBUTE( EGL_LEVEL ), |
| | | ATTRIBUTE( EGL_MAX_PBUFFER_HEIGHT ), |
| | | ATTRIBUTE( EGL_MAX_PBUFFER_WIDTH ), |
| | | ATTRIBUTE( EGL_MAX_PBUFFER_PIXELS ), |
| | | ATTRIBUTE( EGL_NATIVE_RENDERABLE ), |
| | | ATTRIBUTE( EGL_NATIVE_VISUAL_ID ), |
| | | ATTRIBUTE( EGL_NATIVE_VISUAL_TYPE ), |
| | | ATTRIBUTE( EGL_SAMPLES ), |
| | | ATTRIBUTE( EGL_SAMPLE_BUFFERS ), |
| | | ATTRIBUTE( EGL_SURFACE_TYPE ), |
| | | ATTRIBUTE( EGL_TRANSPARENT_TYPE ), |
| | | ATTRIBUTE( EGL_TRANSPARENT_BLUE_VALUE ), |
| | | ATTRIBUTE( EGL_TRANSPARENT_GREEN_VALUE ), |
| | | ATTRIBUTE( EGL_TRANSPARENT_RED_VALUE ), |
| | | ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGB ), |
| | | ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGBA ), |
| | | ATTRIBUTE( EGL_MIN_SWAP_INTERVAL ), |
| | | ATTRIBUTE( EGL_MAX_SWAP_INTERVAL ), |
| | | ATTRIBUTE( EGL_LUMINANCE_SIZE ), |
| | | ATTRIBUTE( EGL_ALPHA_MASK_SIZE ), |
| | | ATTRIBUTE( EGL_COLOR_BUFFER_TYPE ), |
| | | ATTRIBUTE( EGL_RENDERABLE_TYPE ), |
| | | ATTRIBUTE( EGL_MATCH_NATIVE_PIXMAP ), |
| | | ATTRIBUTE( EGL_CONFORMANT ), |
| | | }; |
| | | |
| | | |
| | | static void dumpconfig(_THIS, EGLConfig config) |
| | | { |
| | | int attr; |
| | | for (attr = 0 ; attr<sizeof(attributes)/sizeof(Attribute) ; attr++) { |
| | | EGLint value; |
| | | _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, attributes[attr].attribute, &value); |
| | | SDL_Log("\t%-32s: %10d (0x%08x)\n", attributes[attr].name, value, value); |
| | | } |
| | | } |
| | | |
| | | #endif /* DUMP_EGL_CONFIG */ |
| | | |
| | | int |
| | | SDL_EGL_ChooseConfig(_THIS) |
| | |
| | | break; /* we found an exact match! */ |
| | | } |
| | | } |
| | | |
| | | #ifdef DUMP_EGL_CONFIG |
| | | dumpconfig(_this, _this->egl_data->egl_config); |
| | | #endif |
| | | |
| | | return 0; |
| | | } |
| | |
| | | if (_this->gl_config.share_with_current_context) { |
| | | share_context = (EGLContext)SDL_GL_GetCurrentContext(); |
| | | } |
| | | |
| | | #if SDL_VIDEO_DRIVER_ANDROID |
| | | if ((_this->gl_config.flags & SDL_GL_CONTEXT_DEBUG_FLAG) != 0) { |
| | | /* If SDL_GL_CONTEXT_DEBUG_FLAG is set but EGL_KHR_debug unsupported, unset. |
| | | * This is required because some Android devices like to complain about it |
| | | * by "silently" failing, logging a hint which could be easily overlooked: |
| | | * E/libEGL (26984): validate_display:255 error 3008 (EGL_BAD_DISPLAY) |
| | | * The following explicitly checks for EGL_KHR_debug before EGL 1.5 |
| | | */ |
| | | int egl_version_major = _this->egl_data->egl_version_major; |
| | | int egl_version_minor = _this->egl_data->egl_version_minor; |
| | | if (((egl_version_major < 1) || (egl_version_major == 1 && egl_version_minor < 5)) && |
| | | !SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_debug")) { |
| | | /* SDL profile bits match EGL profile bits. */ |
| | | _this->gl_config.flags &= ~SDL_GL_CONTEXT_DEBUG_FLAG; |
| | | } |
| | | } |
| | | #endif |
| | | |
| | | /* Set the context version and other attributes. */ |
| | | if ((major_version < 3 || (minor_version == 0 && profile_es)) && |
| | |
| | | } |
| | | |
| | | if (egl_context != NULL && egl_context != EGL_NO_CONTEXT) { |
| | | SDL_EGL_MakeCurrent(_this, NULL, NULL); |
| | | _this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context); |
| | | } |
| | | |
| | |
| | | /* max 2 values plus terminator. */ |
| | | EGLint attribs[3]; |
| | | int attr = 0; |
| | | |
| | | |
| | | EGLSurface * surface; |
| | | |
| | | if (SDL_EGL_ChooseConfig(_this) != 0) { |
| | |
| | | return EGL_NO_SURFACE; |
| | | } |
| | | } |
| | | |
| | | |
| | | attribs[attr++] = EGL_NONE; |
| | | |
| | | surface = _this->egl_data->eglCreateWindowSurface( |