Last active
September 12, 2021 07:56
-
-
Save Hiradur/781033a9d183b0e98f34 to your computer and use it in GitHub Desktop.
Shell sript to build glshim and and run games with it on Raspberry Pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Original author: Hiradur | |
# License: CC0 | |
# Purpose: Build and update glshim, glues and TinyGLES, set up correct paths for programs | |
set -eu # stop script on errors | |
GLWRAPPER_INSTALL_DIR=~/glwrapper # source code and binary files will be placed here | |
# if no arguments are given | |
# download/update glshim, glues and tinygles code and compile | |
if [ $# = 0 ]; then | |
echo "Attempting to build glshim and glues" | |
echo "Make sure you are connected to the internet and" | |
echo "cmake and libx11-dev are installed (sudo apt-get install cmake libx11-dev)" | |
if [ ! -e "$GLWRAPPER_INSTALL_DIR" ]; then | |
mkdir -p $GLWRAPPER_INSTALL_DIR | |
fi | |
#### glshim #### | |
echo "Building glshim..." | |
cd $GLWRAPPER_INSTALL_DIR | |
if [ ! -e "glshim" ]; then | |
echo "Downloading glshim source code..." | |
git clone https://github.com/lunixbochs/glshim.git # download glshim source code if not present | |
fi | |
cd glshim | |
echo "switching to unstable-branch..." | |
git checkout unstable # switch to unstable branch | |
echo "checking for updates..." | |
git pull # check for updates | |
echo "starting build..." | |
# configure build | |
cmake . # configure build | |
make GL -j4 # compile | |
#### glues #### | |
echo "Building glues..." | |
cd $GLWRAPPER_INSTALL_DIR | |
if [ ! -e "glues" ]; then | |
echo "Downloading glues source code..." | |
git clone https://github.com/lunixbochs/glues.git | |
fi | |
cd glues | |
echo "switching to glu-branch..." | |
git checkout glu | |
echo "checking for updates..." | |
git pull | |
# copy gl header files from glshim | |
if [ ! -e "include/GL" ]; then | |
mkdir include/GL | |
fi | |
cp -r $GLWRAPPER_INSTALL_DIR/glshim/include/GL/* include/GL | |
echo "starting build..." | |
cmake . | |
make -j4 | |
#### TinyGLES #### | |
# Only available on RPi2 (armv7) | |
if [ $(grep -c ARMv7 /proc/cpuinfo) > 0 ]; then | |
cd ${GLWRAPPER_INSTALL_DIR} | |
if [ ! -e "tinygles" ]; then | |
echo "Downloading TinyGLES source code..." | |
git clone https://github.com/lunixbochs/tinygles.git | |
fi | |
cd tinygles | |
echo "checking for updates..." | |
git pull | |
cmake . | |
make -j4 | |
fi | |
echo "$(tput setaf 2)All libraries were successfully built$(tput sgr 0)" | |
else # arguments received, set up paths and start game | |
echo "Starting game $1" | |
LD_LIBRARY_PATH=${GLWRAPPER_INSTALL_DIR}/glshim/lib:${GLWRAPPER_INSTALL_DIR}/glues | |
# use TinyGLES as renderer if argument is set | |
if [ "$#" -ne 1 ]; then | |
echo "using TinyGLES software renderer" | |
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GLWRAPPER_INSTALL_DIR}/tinygles/lib | |
fi | |
# make LD_LIBRARY_PATH available to subprocesses (ie the game) | |
export LD_LIBRARY_PATH | |
# start the game | |
$1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment