Skip to content

Commit 934b629

Browse files
committed
OpenGL (Android): request GLES 2+
1 parent 90068ab commit 934b629

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/detection/opengl/opengl_shared.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#if __has_include(<GL/gl.h>)
55
#include <GL/gl.h>
6-
#elif __has_include(<OpenGL/gl.h>)
6+
#elif __APPLE__
77
#define GL_SILENCE_DEPRECATION 1
88
#include <OpenGL/gl.h>
99
#else
@@ -64,9 +64,12 @@ static const char* eglHandleContext(FFOpenGLResult* result, EGLData* data)
6464
return NULL;
6565
}
6666

67-
static const char* eglHandleSurface(FFOpenGLResult* result, EGLData* data)
67+
static const char* eglHandleSurface(FFOpenGLResult* result, EGLData* data, bool gles)
6868
{
69-
data->context = data->ffeglCreateContext(data->display, data->config, EGL_NO_CONTEXT, (EGLint[]){EGL_NONE});
69+
data->context = data->ffeglCreateContext(data->display, data->config, EGL_NO_CONTEXT, (EGLint[]){
70+
EGL_CONTEXT_CLIENT_VERSION, gles ? 2 : 1,
71+
EGL_NONE
72+
});
7073
if(data->context == EGL_NO_CONTEXT)
7174
return "eglCreateContext returned EGL_NO_CONTEXT";
7275

@@ -78,10 +81,11 @@ static const char* eglHandleSurface(FFOpenGLResult* result, EGLData* data)
7881
static const char* eglHandleDisplay(FFOpenGLResult* result, EGLData* data)
7982
{
8083
// try use OpenGL API. If failed, use the default API (usually OpenGL ES)
81-
data->ffeglBindAPI(EGL_OPENGL_API);
84+
bool gles = !data->ffeglBindAPI(EGL_OPENGL_API);
8285

8386
EGLint eglConfigCount;
8487
data->ffeglGetConfigs(data->display, &data->config, 1, &eglConfigCount);
88+
8589
if(eglConfigCount == 0)
8690
return "eglGetConfigs returned 0 configs";
8791

@@ -94,7 +98,7 @@ static const char* eglHandleDisplay(FFOpenGLResult* result, EGLData* data)
9498
if(data->surface == EGL_NO_SURFACE)
9599
return "eglCreatePbufferSurface returned EGL_NO_SURFACE";
96100

97-
const char* error = eglHandleSurface(result, data);
101+
const char* error = eglHandleSurface(result, data, gles);
98102
data->ffeglDestroySurface(data->display, data->surface);
99103
return error;
100104
}
@@ -148,7 +152,7 @@ const char* ffOpenGLDetectByEGL(FFOpenGLResult* result)
148152
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglDestroySurface);
149153
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglTerminate);
150154

151-
FF_SUPPRESS_IO();
155+
// FF_SUPPRESS_IO();
152156
return eglHandleData(result, &eglData);
153157
}
154158

0 commit comments

Comments
 (0)