From 7f4d815dde5b69becffa5bdc9b8fc0c52bfbf855 Mon Sep 17 00:00:00 2001 From: Deve Date: Mon, 22 Aug 2016 20:05:36 +0200 Subject: [PATCH] Request GLES 3.0 context and fallback to 2.0 if not available. --- .../source/Irrlicht/COGLES2Driver.cpp | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp index e9b8e7efa..a7243905c 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp +++ b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp @@ -123,13 +123,6 @@ namespace video EGL_NONE, 0 #endif }; - EGLint contextAttrib[] = - { -#ifdef EGL_VERSION_1_3 - EGL_CONTEXT_CLIENT_VERSION, 2, -#endif - EGL_NONE, 0 - }; EGLConfig config; EGLint num_configs; @@ -242,11 +235,41 @@ namespace video eglBindAPI(EGL_OPENGL_ES_API); #endif os::Printer::log("Creating EglContext..."); - EglContext = eglCreateContext(EglDisplay, config, EGL_NO_CONTEXT, contextAttrib); + EglContext = EGL_NO_CONTEXT; + + if (!Params.ForceLegacyDevice) + { + os::Printer::log("Trying to create Context for OpenGL-ES3."); + + EGLint contextAttrib[] = + { + #ifdef EGL_VERSION_1_3 + EGL_CONTEXT_CLIENT_VERSION, 3, + #endif + EGL_NONE, 0 + }; + + EglContext = eglCreateContext(EglDisplay, config, EGL_NO_CONTEXT, contextAttrib); + } + if (EGL_NO_CONTEXT == EglContext) { - os::Printer::log("FAILED\n"); - os::Printer::log("Could not create Context for OpenGL-ES2 display."); + os::Printer::log("Trying to create Context for OpenGL-ES2."); + + EGLint contextAttrib[] = + { + #ifdef EGL_VERSION_1_3 + EGL_CONTEXT_CLIENT_VERSION, 2, + #endif + EGL_NONE, 0 + }; + + EglContext = eglCreateContext(EglDisplay, config, EGL_NO_CONTEXT, contextAttrib); + if (EGL_NO_CONTEXT == EglContext) + { + os::Printer::log("FAILED\n"); + os::Printer::log("Could not create Context for OpenGL-ES2 display."); + } } eglMakeCurrent(EglDisplay, EglSurface, EglSurface, EglContext);