mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
EGL: OpenGL ES 3.0 contexts can now be created without the EGL_KHR_create_context extension.
Fixes bugzilla #2994.
This commit is contained in:
parent
d5a578531b
commit
a4f0daedae
@ -414,6 +414,9 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
|||||||
|
|
||||||
EGLContext egl_context, share_context = EGL_NO_CONTEXT;
|
EGLContext egl_context, share_context = EGL_NO_CONTEXT;
|
||||||
EGLint profile_mask = _this->gl_config.profile_mask;
|
EGLint profile_mask = _this->gl_config.profile_mask;
|
||||||
|
EGLint major_version = _this->gl_config.major_version;
|
||||||
|
EGLint minor_version = _this->gl_config.minor_version;
|
||||||
|
SDL_bool profile_es = (profile_mask == SDL_GL_CONTEXT_PROFILE_ES);
|
||||||
|
|
||||||
if (!_this->egl_data) {
|
if (!_this->egl_data) {
|
||||||
/* The EGL library wasn't loaded, SDL_GetError() should have info */
|
/* The EGL library wasn't loaded, SDL_GetError() should have info */
|
||||||
@ -425,12 +428,18 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set the context version and other attributes. */
|
/* Set the context version and other attributes. */
|
||||||
if (_this->gl_config.major_version < 3 && _this->gl_config.flags == 0 &&
|
if ((major_version < 3 || (minor_version == 0 && profile_es)) &&
|
||||||
(profile_mask == 0 || profile_mask == SDL_GL_CONTEXT_PROFILE_ES)) {
|
_this->gl_config.flags == 0 &&
|
||||||
/* Create a context without using EGL_KHR_create_context attribs. */
|
(profile_mask == 0 || profile_es)) {
|
||||||
if (profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
|
/* Create a context without using EGL_KHR_create_context attribs.
|
||||||
|
* When creating a GLES context without EGL_KHR_create_context we can
|
||||||
|
* only specify the major version. When creating a desktop GL context
|
||||||
|
* we can't specify any version, so we only try in that case when the
|
||||||
|
* version is less than 3.0 (matches SDL's GLX/WGL behavior.)
|
||||||
|
*/
|
||||||
|
if (profile_es) {
|
||||||
attribs[attr++] = EGL_CONTEXT_CLIENT_VERSION;
|
attribs[attr++] = EGL_CONTEXT_CLIENT_VERSION;
|
||||||
attribs[attr++] = SDL_max(_this->gl_config.major_version, 1);
|
attribs[attr++] = SDL_max(major_version, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef EGL_KHR_create_context
|
#ifdef EGL_KHR_create_context
|
||||||
@ -439,9 +448,9 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
|||||||
*/
|
*/
|
||||||
if (SDL_EGL_HasExtension(_this, "EGL_KHR_create_context")) {
|
if (SDL_EGL_HasExtension(_this, "EGL_KHR_create_context")) {
|
||||||
attribs[attr++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
|
attribs[attr++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
|
||||||
attribs[attr++] = _this->gl_config.major_version;
|
attribs[attr++] = major_version;
|
||||||
attribs[attr++] = EGL_CONTEXT_MINOR_VERSION_KHR;
|
attribs[attr++] = EGL_CONTEXT_MINOR_VERSION_KHR;
|
||||||
attribs[attr++] = _this->gl_config.minor_version;
|
attribs[attr++] = minor_version;
|
||||||
|
|
||||||
/* SDL profile bits match EGL profile bits. */
|
/* SDL profile bits match EGL profile bits. */
|
||||||
if (profile_mask != 0 && profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
|
if (profile_mask != 0 && profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
|
||||||
@ -465,7 +474,7 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
|||||||
attribs[attr++] = EGL_NONE;
|
attribs[attr++] = EGL_NONE;
|
||||||
|
|
||||||
/* Bind the API */
|
/* Bind the API */
|
||||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
|
if (profile_es) {
|
||||||
_this->egl_data->eglBindAPI(EGL_OPENGL_ES_API);
|
_this->egl_data->eglBindAPI(EGL_OPENGL_ES_API);
|
||||||
} else {
|
} else {
|
||||||
_this->egl_data->eglBindAPI(EGL_OPENGL_API);
|
_this->egl_data->eglBindAPI(EGL_OPENGL_API);
|
||||||
|
Loading…
Reference in New Issue
Block a user