The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Raspberry Pi (Raspbian) + OpenglES + no X
cleger


Joined: 06 Oct 2016
Posts: 4
Greetings.

I'm trying to build an application on Raspberry Pi (version 1A or 2B+)/raspbian which:

- uses SDL for event handling, image loading, sound, etc.
- uses OpenglES for rendering
- runs without X (just to save memory)

I've read a great many posts where people help each other build or run SDL+OpenglES apps, but I can never completely nail down what config people are dealing with.

My questions:
- Can I build and run the above app with the stock SDL2-dev library that I can get from the Raspbian ppt?
- In order to build and run my app, must I first build SDL2 with rpi-related flags enabled, and use a few disables, such as --disable-video-x11, --disable-video-opengl, etc.?

My main dilemma is that I don't know whether SDL for Raspbian 'prefers' or 'assumes' it is running inside of, or outside of, X.

Anyone who wants to throw a wall of text at me explaining how SDL is configured for this would be my hero.

Thank you in advance.
Raspberry Pi (Raspbian) + OpenglES + no X
MrOzBarry


Joined: 26 Jun 2010
Posts: 620
I'd say build it yourself, distribute the library files with your app.  I think most people are building with the flags you mentioned.  Here is the script the buildbot uses to test raspberry pi builds.  You might not need all of those flags (ie prefix, sysroot, etc.), but that's a good starting point for a known, good configure.  There are a few others that probably do more SDL apps for raspberry pi than myself that could give you better directions, but that's at least a start.

On Thu, Oct 6, 2016 at 11:59 AM, cleger wrote:
Quote:
Greetings.

I'm trying to build an application on Raspberry Pi (version 1A or 2B+)/raspbian which:

- uses SDL for event handling, image loading, sound, etc.
- uses OpenglES for rendering
- runs without X (just to save memory)

I've read a great many posts where people help each other build or run SDL+OpenglES apps, but I can never completely nail down what config people are dealing with.

My questions:
- Can I build and run the above app with the stock SDL2-dev library that I can get from the Raspbian ppt?
- In order to build and run my app, must I first build SDL2 with rpi-related flags enabled, and use a few disables, such as --disable-video-x11, --disable-video-opengl, etc.?

My main dilemma is that I don't know whether SDL for Raspbian 'prefers' or 'assumes' it is running inside of, or outside of, X.

Anyone who wants to throw a wall of text at me explaining how SDL is configured for this would be my hero.

Thank you in advance.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Raspberry Pi (Raspbian) + OpenglES + no X
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
2016-10-06 12:59 GMT-03:00 cleger:
Quote:
Greetings.

I'm trying to build an application on Raspberry Pi (version 1A or 2B+)/raspbian which:

- uses SDL for event handling, image loading, sound, etc.
- uses OpenglES for rendering
- runs without X (just to save memory)

I've read a great many posts where people help each other build or run SDL+OpenglES apps, but I can never completely nail down what config people are dealing with.

My questions:
- Can I build and run the above app with the stock SDL2-dev library that I can get from the Raspbian ppt?



It depends on how that library was built. If it has both X11 and RPi video backends in it, you need to make sure the right one is selected when launching your app (SDL by default just goes through the list of video backends compiled in until one works). That's why I suggest disabling X11 support when building for the RPi, since it doesn't really work and gets in the way.


 
Quote:

- In order to build and run my app, must I first build SDL2 with rpi-related flags enabled, and use a few disables, such as --disable-video-x11, --disable-video-opengl, etc.?

My main dilemma is that I don't know whether SDL for Raspbian 'prefers' or 'assumes' it is running inside of, or outside of, X.




It doesn't assume anything, in terms of "preference", you can see the video backend selection logic here: https://hg.libsdl.org/SDL/file/tip/src/video/SDL_video.c#l472


It can be affected by the environment variable SDL_VIDEODRIVER, otherwise it'll go through the bootstrap array, where X11 is listed in second place thus it'll be initialized before the RPi direct hardware backend.


Gabriel.
cleger


Joined: 06 Oct 2016
Posts: 4
Thank you MrOzBarry and Gabriel, I think you answered what I need to know. I'll post again whenever I get a chance to make progress on this. Cheers![/quote]
blacktm


Joined: 08 Oct 2016
Location: Washington, DC
cleger – I've also had to figure this out for my little 2D graphics engine: https://github.com/simple2d/simple2d

Unfortunatly, the Raspbian packages are configured for desktop OpenGL and X11, so I currently have the Simple 2D install script build SDL2 from source, which works great (and is very fast) using OpenGL ES without X. For a shortcut, you can build/install just SDL2 (along with SDL2_mixer, SDL2_image, SDL2_ttf, and SMPEG2) by running the script with the `--sdl` flag:

Code:
simple2d.sh install --sdl


See all the details under the hood here: https://github.com/simple2d/simple2d/blob/v0.4.1/bin/simple2d.sh#L280

I might also recommend giving Simple 2D a try, browse through the internals – lots of SDL examples on display here that work across platforms/OSes, GL2, GL3, GLES, etc.

Good luck, and happy to answer any more Q's you have, blockers you encounter. SDL is awesome and I'm always looking for ways to make it easier for folks to get started.

Tom
Now working
cleger


Joined: 06 Oct 2016
Posts: 4
Hi all,

Thanks for the feedback it was extremely helpful.

After a very long sequence of distractions...

Here is where I am: I was able to build SDL2 and run an OpenGL-enabled program, entirely from the RPI console - which is amazing!

What remains weird is this:

- I was entirely unable to build or run the app without specifying LD_LIBRARY_PATH=/opt/vc/lib:./lib (where the first path holds opengl es and the latter was where I had my self-built SDL2 libs). No ordering of -L parameters seemed to override the system default of looking for libOpenGLES2 in /usr/lib/arm-etc. which for some reason never works (x11 dependent?).

- for some reason even though building SDL2 produce three separate identical (diff==empty) lib files named libSDL2-2.0.so, libSDL2-2.0.so.0.4.1, libSDL2.so, the only way the linker and the runtime are happy is if I have at least libSDL2.so in my ld-library-path, along with a symlink to it called libSDL2-2.0.s0.0. If the symlink is missing, no go. If I have the lib with only the name of the symlink, no go. If both names are there, with files of exactly the same content, all is good. Anybody know why? I'm not by any means an expert in binaries and linking matters.

Also, I've tried all manner of SDL_SetHint and SDL_WINDOW_INPUT_GRABBED values at initialization, but I always get ^[[6~ showing up a bunch of times in the console output. I'll probably post a new question about that.

Thanks so much for the feedback so far, it was what I needed to get going and now I'm back in this fun game!