main readme additions about building on raspberry pi

This commit is contained in:
ohsqueezy 2023-04-10 16:27:07 -04:00
parent 6777f26d87
commit 297fdef6e8
1 changed files with 44 additions and 3 deletions

View File

@ -71,6 +71,47 @@ This is the platform SPACEBOX is built on, so it has the most straightforward bu
Exporting a browser build with [Emscripten][] and its built-in version of SDL has worked well on a few projects. The general process is to create a separate make target that uses Emscripten's C++ to WebAssembly compiler. See the browser webcam demo below for an example.
### Raspberry Pi
Raspberry Pi builds, like Android and Emscripten, require using OpenGL ES. There is currently only an in-progress version of the cube demo to test exporting to Raspberry Pi. The build process is similar to standard desktop Linux with the `-D __PI__` compiler flag used to activate some Pi-specific code in the framework. GLEW is not available for OpenGL ES, so GLES headers are included directly from the expected system directories.
#### SDL
SDL should be built with `--enable-video-kmsdrm`. This will require the installation of external packages. OpenGL ES will also need to be installed.
sudo apt install libgbm-dev libdrm-dev libegl-dev libgles2-mesa-dev
Otherwise, SDL can be installed in the same way [described above](#libSDL2).
#### KMS
If using the Raspberry Pi without X-windows, SDL will run in KMS mode. The config for the latest versions of the Raspberry Pi OS Lite should be setup correctly by default, and the installation of SDL from source should enable KMS by default if the necessary packages above have been installed. However, it is good to verify that `/boot/config.txt` is setup correctly and that SDL is built with KMS video output enabled.
To verify `/boot/config.txt`, make sure the line `dtoverlay=vc4-kms-v3d` is included in the file. This activates KMS mode for the console instead of either Fake KMS or the older framebuffer modes.
#### Build the `testgles2.c` SDL test
In the SDL source downloaded in the previous step, there is a `test/testgles2.c` program that draws a rotating cube using GLES. This can be used to verify that the SDL installation is working on the Pi.
cd [SDL_source]/test/
gcc $(sdl-config --cflags --libs) -LSDL_test -o testgles
./testgles
#### Raspberry Pi Model 3B+
This model only supports up to Open GL ES 2.0.
#### Raspberry Pi Model 4
This model supports up to Open GL ES 3.2.
#### External demos
Try these non-SPACEBOX demos for verifying the Raspberry Pi OpenGL ES setup with KMS.
* [kmscube](https://gitlab.freedesktop.org/mesa/kmscube)
* [KMS GLSL](https://github.com/astefanutti/kms-glsl)
### Android
The [fill_screen demo][] has a working example of how to build for Android. It may be worthwhile to read the [SDL wiki Android page][] and [SDL docs Android README][] and compile an SDL example for Linux before doing a SPACEBOX Android build. The source distributions for SDL, SDL image, SDL ttf, and SDL mixer, and the Android SDK are required.
@ -207,7 +248,7 @@ These steps were taken to build the fill_screen demo for Android. The Android SD
$ ANDROID_SDK_ROOT=$HOME/local/Android ./gradlew build
### OS X, Windows, Raspberry Pi
### OS X, Windows
Builds for these platforms have only passed the proof of concept phase. An early version of SPACEBOX was compiled for each of them, but none of the demos have been compiled for them in their current form, so there is only some broken code available in the cube demo Makefile.
@ -335,7 +376,7 @@ Contact
[SDL source package]: http://libsdl.org/download-2.0.php
[blog post about elliptical grid mapping equations]: http://squircular.blogspot.com/2015/09/mapping-circle-to-square.html
[Emscripten]: https://emscripten.org/
[Gunkiss]: https://git.nugget.fun/nugget/gunkiss
[Pepy]: https://git.nugget.fun/nugget/pepy
[Gunkiss]: https://open.shampoo.ooo/shampoo/gunkiss
[Pepy]: https://open.shampoo.ooo/shampoo/pepy
[demo/fill_screen/Makefile]: demo/fill_screen/Makefile
[fill_screen demo]: demo/fill_screen