Skip to content

Commit 4937ccf

Browse files
committed
OpenGL (EGL): prefer surfaceless display
1 parent d0d29c1 commit 4937ccf

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/detection/opengl/opengl_shared.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglG
2727
#if defined(FF_HAVE_EGL) || __has_include(<EGL/egl.h>)
2828
#include "common/io/io.h"
2929

30+
#define EGL_EGL_PROTOTYPES 1
31+
#define EGL_EGLEXT_PROTOTYPES 1
3032
#include <EGL/egl.h>
33+
#include <EGL/eglext.h>
3134

3235
typedef struct EGLData
3336
{
@@ -102,9 +105,20 @@ static const char* eglHandleData(FFOpenGLResult* result, EGLData* data)
102105
if(!data->ffglGetString)
103106
return "eglGetProcAddress(glGetString) returned NULL";
104107

105-
data->display = data->ffeglGetDisplay(EGL_DEFAULT_DISPLAY);
106-
if(data->display == EGL_NO_DISPLAY)
107-
return "eglGetDisplay returned EGL_NO_DISPLAY";
108+
#ifdef EGL_PLATFORM_SURFACELESS_MESA
109+
PFNEGLGETPLATFORMDISPLAYPROC ffeglGetPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYPROC) data->ffeglGetProcAddress("eglGetPlatformDisplay");
110+
if (ffeglGetPlatformDisplay)
111+
data->display = ffeglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA, NULL, NULL);
112+
113+
if(!ffeglGetPlatformDisplay || data->display == EGL_NO_DISPLAY)
114+
#endif
115+
116+
{
117+
data->display = data->ffeglGetDisplay(EGL_DEFAULT_DISPLAY);
118+
if(data->display == EGL_NO_DISPLAY)
119+
return "eglGetDisplay returned EGL_NO_DISPLAY";
120+
}
121+
108122

109123
EGLint major, minor;
110124
if(data->ffeglInitialize(data->display, &major, &minor) == EGL_FALSE)

0 commit comments

Comments
 (0)