RichardRussell
Posts: 154
Joined: Thu Jun 21, 2012 10:48 am

OpenGL/SDL2 issue

Tue Mar 21, 2017 6:04 pm

I'm using SDL 2.0.2 (from the repository) in windowed mode on an RPi 3, using the 'experimental' OpenGL driver, and all the normal 2D SDL functions work as I would expect (and appear to be accelerated). However even the simplest attempt to access the OpenGL context directly isn't working:

Code: Select all

glcontext = SDL_GL_CreateContext(window);
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(window);
This works perfectly fine on other platforms (Windows, Linux, Mac OS) but on the RPi instead of clearing the window to black it clears it to green, and changing the parameters of glClearColor() seems to make no difference! I am at a loss to understand what is going on here.

The only other indication of a problem is this warning on the console:

Code: Select all

libGL error: MESA-LOADER: failed to retrieve device information
however I suspect this is a red herring because glxgears reports the same warning but otherwise works correctly.

Can anybody suggest why my trivial SDL program isn't working on the RPi?

Richard.

knobby67
Posts: 40
Joined: Fri Mar 09, 2012 9:18 am

Re: OpenGL/SDL2 issue

Tue May 30, 2017 10:40 am

Hi I came to make almost exactly this post.
What I'm doing is porting code to pi. It uses opengl and sdl2. I installed all the sdl2 stuff with apt-get. When I compiled my code it ran painfully slow, 1-2 frames a second. After some searching I found I need to go into raspi-config and set the G1 GL ( full kms ) option. I did this, compiled and my game starts up. However during the loading it reports the above error "libGL error: MESA-LOADING failed " and also "MESA-LOADING : failed to retrieve device information"

I guessing this is to do with the sdl2 libs from the repo being cross compiled with mesa rather that against the accelerated libs ?

Does anyone know how I can get SDL2 running with acceleration? Thanks

NJJ
Posts: 1
Joined: Tue May 03, 2016 7:29 am

Re: OpenGL/SDL2 issue

Fri Jun 23, 2017 8:33 am

The simple way to do it is to first off install love2d from the repositories. This activates the correct version of sdl2, even though it is an older copy of love2d. If you run "love" you will get a software emulated version of OpenGL.

Next, activate Anholt's OpenGL driver (fake KMS as the real KMS version seems to have a bug that prevents booting).
Update the kernel to the latest version which will pull in a whole lot of OpenGL fixes that make acceleration through SDL2 work nicely.

Love2d can be easily updated by downloading the .deb files from their website (armhf versions). Then just type "love" in a terminal and you will get a smooth accelerated splash screen - supertoast. That should prove that SDL2 is working. You may need to install some audio libraries if it complains.

The experimental opengl driver is already very impressive - I have been able to get over 50fps with a 1920x1080 full screen.

HeadCase
Posts: 43
Joined: Sat Sep 03, 2011 8:11 am

Re: OpenGL/SDL2 issue

Fri Jun 23, 2017 8:38 am

The simple way to do it is to first off install love2d from the repositories. This activates the correct version of sdl2, even though it is an older copy of love2d. If you run "love" you will get a software emulated version of OpenGL.

Next, activate Anholt's OpenGL driver (fake KMS as the real KMS version seems to have a bug that prevents booting).
Update the kernel to the latest version which will pull in a whole lot of OpenGL fixes that make acceleration through SDL2 work nicely.

Love2d can be easily updated by downloading the .deb files from their website (armhf versions). Then just type "love" in a terminal and you will get a smooth accelerated splash screen - supertoast. That should prove that SDL2 is working. You may need to install some audio libraries if it complains. A warning message is posted about MESA versions but it seems to be benign.

The experimental opengl driver is already very impressive - I have been able to get over 50fps with a 1920x1080 full screen using the luajit framework.

Return to “OpenGLES”

Who is online

Users browsing this forum: No registered users and 2 guests