From 359910762d459a798132e06e4d8a0dba692f8a71 Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Thu, 18 Jan 2018 17:11:22 -0500 Subject: [PATCH] GraphicsWindowSDL2: support setting up GLESv2 context for android --- components/sdlutil/sdlgraphicswindow.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/sdlutil/sdlgraphicswindow.cpp b/components/sdlutil/sdlgraphicswindow.cpp index c2cf2536e..de82ca850 100644 --- a/components/sdlutil/sdlgraphicswindow.cpp +++ b/components/sdlutil/sdlgraphicswindow.cpp @@ -92,9 +92,18 @@ void GraphicsWindowSDL2::init() SDL_GLContext oldCtx = SDL_GL_GetCurrentContext(); #if defined(OPENGL_ES) || defined(ANDROID) - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + int major = 1; + int minor = 1; + char *ver = getenv("OPENMW_GLES_VERSION"); + + if (ver && strcmp(ver, "2") == 0) { + major = 2; + minor = 0; + } + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor); #endif mContext = SDL_GL_CreateContext(mWindow);