Page 1 of 1

OpenGL on Pi - confused!

Posted: Tue Jul 10, 2018 8:16 am
by ensan
Hi, Forgive the newbie question but I have some desktop GL from an old Linux side project that I'm now compiling on the Pi (3B+). I followed the typical OpenGL dev route on Linux but appreciate the Pi differs.

Following the typical installation of mesa for desktop GL dev I've compiled the project and it runs (kind of) with full KMS desktop GL driver enabled (via raspi-config).

So I'm working backwards from my executable to understand what I have produced (naively following the typical Linux GL dev route) with the hope of learning how I should be doing things on the Pi (I know it's a bit arse about face but it's an approach. Neither top down nor bottom up but more in from the side like a crab on a hot plate).

I LDD'd my executable and get the following:

linux-vdso.so.1 (0x7ed70000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76fa8000)
libGLU.so.1 => /usr/lib/arm-linux-gnueabihf/libGLU.so.1 (0x76f2a000)
libGL.so.1 => /usr/lib/arm-linux-gnueabihf/libGL.so.1 (0x76eb8000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76d51000)
libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x76c09000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76b8a000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x76b5d000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76b34000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x769f5000)
/lib/ld-linux-armhf.so.3 (0x76fbe000)
libexpat.so.1 => /lib/arm-linux-gnueabihf/libexpat.so.1 (0x769c3000)
libxcb-dri3.so.0 => /usr/lib/arm-linux-gnueabihf/libxcb-dri3.so.0 (0x769b0000)
libxcb-present.so.0 => /usr/lib/arm-linux-gnueabihf/libxcb-present.so.0 (0x7699d000)
libxcb-sync.so.1 => /usr/lib/arm-linux-gnueabihf/libxcb-sync.so.1 (0x76987000)
libxshmfence.so.1 => /usr/lib/arm-linux-gnueabihf/libxshmfence.so.1 (0x76975000)
libglapi.so.0 => /usr/lib/arm-linux-gnueabihf/libglapi.so.0 (0x7693c000)
libXext.so.6 => /usr/lib/arm-linux-gnueabihf/libXext.so.6 (0x7691d000)
libXdamage.so.1 => /usr/lib/arm-linux-gnueabihf/libXdamage.so.1 (0x7690a000)
libXfixes.so.3 => /usr/lib/arm-linux-gnueabihf/libXfixes.so.3 (0x768f5000)
libX11-xcb.so.1 => /usr/lib/arm-linux-gnueabihf/libX11-xcb.so.1 (0x768e3000)
libX11.so.6 => /usr/lib/arm-linux-gnueabihf/libX11.so.6 (0x767c0000)

libxcb.so.1 => /usr/lib/arm-linux-gnueabihf/libxcb.so.1 (0x76791000)
libxcb-glx.so.0 => /usr/lib/arm-linux-gnueabihf/libxcb-glx.so.0 (0x7676d000)
libxcb-dri2.so.0 => /usr/lib/arm-linux-gnueabihf/libxcb-dri2.so.0 (0x76759000)
libXxf86vm.so.1 => /usr/lib/arm-linux-gnueabihf/libXxf86vm.so.1 (0x76744000)
libdrm.so.2 => /usr/lib/arm-linux-gnueabihf/libdrm.so.2 (0x76727000)
libXau.so.6 => /usr/lib/arm-linux-gnueabihf/libXau.so.6 (0x7671c000)
libXdmcp.so.6 => /usr/lib/arm-linux-gnueabihf/libXdmcp.so.6 (0x76707000)
libbsd.so.0 => /lib/arm-linux-gnueabihf/libbsd.so.0 (0x766de000)

Based on the above:

- I'm using opengl (libGL) that was compiled using the generic compiler for arm (arm-linux-gnueabihf)
- I'm drawing to an X11 window (libX11)

As mentioned simple rendering code works (issuing draw commands with a shader applied rendering a model presented using index / vertex buffer) but it doesn't take much to break the rendering (drawing a few hundred vertex buffers in a single frame).

Questions:

- Is arm-linux-gnueabihf the right compiler chain?
- Is rendering desktop OpenGL on X11 supported on the Pi under mesa with full KMS desktop drivers enabled?
- With full kms rendering config option set and the above what driver is the code using i.e. how do you determine what driver the opengl commands are being sent to?

Many thanks in advance for enlightening this noob!

Re: OpenGL on Pi - confused!

Posted: Thu Jul 12, 2018 7:21 pm
by ensan
Or put more simply - Can I use standard desktop GL headers / libs (OpenGL 2 / 3) on a raspberry pi or do I need to use OpenGL ES?

Re: OpenGL on Pi - confused!

Posted: Thu Jul 12, 2018 10:20 pm
by Paeryn
If you wrote the code for OpenGL then you use the OpenGL headers. Whilst a lot of OpenGL code will be the the same under OpenGL|ES there are a few differences in that OpenGL|ES is a reduced API targeted at embedded / mobile devices.

The RPi is a native OpenGL|ES 2 device so some features of OpenGL may be less than optimal if they require emulating (either by the hardware having to do more work or outright software emulation) but if your program works fine using the OpenGL drivers and you are happy with it then there isn't any need to convert it to OpenGL|ES.

Re: OpenGL on Pi - confused!

Posted: Fri Jul 13, 2018 10:06 am
by ensan
Many thanks for the reply Paeryn :-)