I am looking for a "Hello World" type example that makes use of OpenGL-ES2 via SDL2. So far I could gather:
- SDL2 that ships with Raspbian does not support OpenGL-ES2 out of the box
- SDL-2.0.3 manually compiled from source should support OpenGL-ES2 in theory
However even with a manually compiled SDL-2.0.3 I can't get OpenGL-ES2 to work, the displays goes black, so something is working, but even a simple glClearColor()/glClear()
doesn't have any effect. The same code via EGL or run via OpenGL on a desktop computer however works as expected.
Source code is available at: https://github.com/Grumbel/rpi-opengl
2 Answers 2
The problem turned out to not be in the code, but in the library path. A simple -L/opt/vc/lib/
added to the compile command line fixed it. Without that the compiler would pick:
/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2
While the right one would be (use ldd
to check):
/opt/vc/lib/libGLESv2.so
On my RPI the file /opt/vc/lib/libGLESv2.so
does not exist.
And libGLESv2.so
gives me a blank screen.
Found that linking to this file works: /opt/vc/lib/libbrcmGLESv2.so
.
In order to compile a small program with both SDL2 and GLES I needed this command line:
g++ -o gltest gltest.cpp -L/opt/vc/lib `sdl2-config --libs` -lbrcmGLESv2