Just simulating the universe
Only Linux (Ubuntu) is supported at this time.
- Installing the graphical library SDL2, and some FreeType fonts:
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libfreetype6-dev fonts-dejavu
Compiling is done by running make.
Try the program by running the command below, with an optional integer argument between 0 and 2:
./spaceprogram.exe
SDL2 v2.0.10 causes a drawing bug: rendering something changes the color of a specific pixel of the last drawn object. This bug however is not present in versions 2.0.8 and 2.0.14. Should it arise, uninstall the libsdl2-dev package, then install this one and this one. Finally, libsdl2-image-dev and libsdl2-ttf-dev may need to be updated after that.
Both the compiling and the runtime GUI can be containerized using Docker. If using that, make sure to rebuild the image with each code change. Additionally, Docker Compose is also supported.
Limitations:
- For now, this only works on Linux.
- This is not space efficient: the resulting image weights 580 MB (
busybox:1.33.1-glibccouldn't be used due to libraries (SDL2) needing to be linked, and static executable failed to build).
Buiding the image:
sudo docker build -t gui-app:1.0 .
Running the containerized GUI (not as root), with runtime arg 2:
sudo docker run \
--net=host \
--env=DISPLAY \
--volume=$HOME/.Xauthority:/root/.Xauthority:rw \
gui-app:1.0 \
./spaceprogram.exe 2
Buiding the image:
sudo docker-compose build
Running the containerized GUI (not as root):
sudo COMMAND="./spaceprogram.exe 2" HOME=$HOME docker-compose up
Note: $HOME content should be the user home directory, not /root/. Giving said path was necessary on Ubuntu 20.04, but not needed on CentOS 7.
