How to get OpenGL.glDrawElements(GL_POINTS, ..) (or GL_LINE_LOOP, GL_LINE_STRIP, GL_LINES) to work with the latest Raspberry Pi? I maintain the pi3d module and, though it works on windows, linux and all the old Raspberry Pis I really want to get it working on the new Pi.

Here is a minimal version of code that shows the problem https://github.com/paddywwoof/test_rpi4

and here is a record of what it looks like https://youtu.be/eyDMb4VVIgk

2 Answers 2

sdl2.video.SDL_GL_SetAttribute(sdl2.video.SDL_GL_CONTEXT_MAJOR_VERSION, 2)
sdl2.video.SDL_GL_SetAttribute(sdl2.video.SDL_GL_CONTEXT_MINOR_VERSION, 1)
sdl2.video.SDL_GL_SetAttribute(sdl2.video.SDL_GL_CONTEXT_PROFILE_MASK, sdl2.video.SDL_GL_CONTEXT_PROFILE_CORE)

There's no such thing as GL 2.1 core, so I would expect your context creation to have failed here, regardless of platform.

But also, at the top you've got USE_ES set, but 2.1 isn't a GLES version, but then I don't see anything trying to create an ES context instead of a desktop GL context anyway.

  • Eric, thanks for input. I have actually tried different combinations but not found any to work if I set the GL_CONTEXT_PROFILE_MASK to GL_CONTEXT_PROFILE_ES Setting to CORE or COMPATIBILITY seems to work with 2.0 or 2.1 SDL2 must do some verification and choose a working profile. However I've done a little more testing and verifed that using PyOpenGL seems to render points and lines OK so it must be something to do with the way I'm using GL. I thought it might be type specs but github.com/paddywwoof/rust_pi3d has same issue. Don't know why triangles ok but others not!
    – paddyg
    Commented Jul 19, 2019 at 21:46
  • Eric, I found the cause of the issue as posted in my answer. It's not really a bug as the logic of culling faces for lines and points is moot. However it is different from behavior on other machines so may indicate something...
    – paddyg
    Commented Jul 20, 2019 at 19:26

The solution turned out to be annoyingly obscure and very simple: The culprit line is


Stops rendering points and lines only on the Raspberry Pi 4. I've not looked through the mesa source code to see why this might be the case (Eric might just know)

The reason for culling front faces is because pi3d was originally set up with clockwise faces so, when culling was later introduced to improve rendering efficiency the front was culled and back visible in the CCW sense. The correct way to do this would have been to define the front using glFrontFace(GL_CW) which is what I've now actually done and it works fine on the RPi4 as well as other architectures.

  • Oh dear! That's an error as far as I can see -- according to the spec cullface should only apply to polygons, which doesn't include points and lines, yet the hardware does seem to apply culling to points and lines. We'll need to fix the driver to disable culling when those prims are being generated. Commented Aug 30, 2019 at 23:11
  • Thanks for reporting back. (Also thanks for all your previous work on the RPi drivers)
    – paddyg
    Commented Aug 31, 2019 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.