GLES (OpenGL ES) on desktop Linux? (customEGLWindowSettings)

I have been working with OF on Android, and realized I have some unexpected rendering which I’d like to debug. I couldn’t quite get debugging OpenGL directly on Android to work, so I thought: as OF on Android uses OpenGL ES (GLES) - why not make a desktop Linux OF application, which uses GLES for rendering, instead of the full OpenGL; and debug that instead? So my question is, generally - is this possible, and how do I do it?

Here is what I have so far: First, I am assuming that GLES is a subset of OpenGL, so it should be possible to run a GLES app to run on desktop; as far as porting goes, it seems possible:

OpenGL ES - Wikipedia

… an application written for OpenGL ES 1.0 should be easily portable to
the desktop OpenGL 1.3; as the OpenGL ES is a stripped-down version of
the API, the reverse may or may not be true, depending on the particular
features used.

Then, there are indicators GLES might run on desktop:

Finally, on my desktop Linux (Ubuntu 14.04), I already have (via libgles1-mesa-lts-vivid package etc) shared object files (that seemingly implement the GLES libraries) that Android OF apps are usually linked against:

$ ls /usr/lib/i386-linux-gnu/mesa-egl/ 

So, this is what I did: first, realized that in context of openFrameworks, the Android window inherits from ofAppBaseGLESWindow:

class ofAppAndroidWindow: public ofAppBaseGLESWindow {

Then, found another class that inherits from the same, ofAppEGLWindow:

class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread

Finally, the only (?) OF example I could find using ofAppEGLWindow is examples/gles/customEGLWindowSettings. Now, this example is apparently for Raspberry Pi, but I tried compiling it on desktop Ubuntu GNU/Linux. First, the git OF version I use is:

openFrameworks$ git log -1
commit 16eca45a1d45a6a98621756cabad0e2a9b85ff44
Author: arturo castro <>
Date:   Sat Sep 19 12:18:44 2015 +0200

Then, I did this:

cd openFrameworks/examples/gles/customEGLWindowSettings
cd src
ln -s ../../../../../openFrameworks/libs/openFrameworks/app/ofAppEGLWindow.cpp .
cd ..
cp openFrameworks/examples/android/androidAudioExample/Makefile .
echo 'USER_LDFLAGS += -lGLESv1_CM -lGLESv2 -lEGL -L/usr/lib/i386-linux-gnu/mesa-egl/' | cat - Makefile | tee Makefile
make Debug

Note that:

  • ofAppEGLWindow.cpp is symlinked, because it is otherwise explicitly excluded in openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/, unless the LINUX_ARM variable is set (via PLATFORM_CORE_EXCLUSIONS); the symlink then forces its compilation under Linux
  • The Makefile being copied is the generic “minimal” Makefile which is also present in other examples (in this version, the customEGLWindowSettings example, otherwise, does not have anything else but a bin/ and src/ subfolders)
  • Additional linking flags are added via the USER_LDFLAGS variable as an added first line in the Makefile

With this, the project for me compiles and links to an executable. When ran, it starts a window with a random color which hangs for a second or two, during which the terminal outputs:

$ ./bin/customEGLWindowSettings_debug
[notice ] ofAppEGLWindow: createSurface(): setting up EGL Display
[notice ] ofAppEGLWindow: createSurface(): EGL Display correctly set 0x9491f70
Segmentation fault (core dumped)

… and then it segfaults and the window dissapears. If I run this program in gdb, I can see this:

Program received signal SIGSEGV, Segmentation fault.
0x08090e09 in ofGetCurrentRenderer () at /path/to/openFrameworks/libs/openFrameworks/app/ofAppRunner.cpp:252
252        return mainLoop()->getCurrentWindow()->renderer();
(gdb) p mainLoop()->getCurrentWindow()
$1 = std::shared_ptr (empty) 0x0

… so clearly, the problem is that mainLoop()->getCurrentWindow() is a null pointer, causing a segfault.

So, with this, it seems that the customEGLWindowSettings example can, even if meant for Raspberry PI, compile and run under Linux - but clearly, there are problems segfaults. My question is: would it be possible to get customEGLWindowSettings to run properly on Linux; if so how - and if not, why (is there something I’m fundamentally misunderstanding about GLES, for example)?

In short, I don’t think there is a way to do it.

It always seemed strange to me as WebGL is based on OpenGL ES (and the iPhone simulator as well). I think those apps (Browsers/Simulators) are running the OpenGL ES code through some kind of re-interpreter that translates it back into regular OpenGL for Desktop systems.

For instance - it looks like this is used for Windows to translate OpenGL ES 2 into DirectX

1 Like

this is possible in linux, there’s actually a PR from someone who got it working a while ago:

i’ve been adding some code lately to do the opposite, have openGL support in platforms where it would usually default to ES:

in general you would need to link against the libraries for GLES as you are doing and change ofConstants to define TARGET_OPENGLES

glfw and tess2 also need to be recompiled, glfw to use GLES and tess2 to use unsigned short indices

1 Like

Interesting! Do you know if this is software rendering?