OpenGL 2 Example - binarycounter/Westonpack GitHub Wiki

Running OpenGL 2 (GLX) Games

Prerequisites:

  • Your game uses OpenGL 2.1 or lower

Required Runtimes:

  • Westonpack 0.2.5 or higher (weston_pkg_0.2.squashfs)
  • Mesapack 0.1.1 or higher (mesa_pkg_0.1.squashfs) (Only if VirGL is used)

Example Script (GL4ES)

#!/bin/bash

# PortMaster preamble
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
if [ -d "/opt/system/Tools/PortMaster/" ]; then
  controlfolder="/opt/system/Tools/PortMaster"
elif [ -d "/opt/tools/PortMaster/" ]; then
  controlfolder="/opt/tools/PortMaster"
elif [ -d "$XDG_DATA_HOME/PortMaster/" ]; then
  controlfolder="$XDG_DATA_HOME/PortMaster"
else
  controlfolder="/roms/ports/PortMaster"
fi
source $controlfolder/control.txt
get_controls

# Adjust these to your paths
GAMEDIR=/$directory/ports/your_port_folder
game_executable="your_game.aarch64"
gptk_filename="YourControls.gptk"
game_libs=$GAMEDIR/libs.${DEVICE_ARCH}/:$LD_LIBRARY_PATH

# Logging
> "$GAMEDIR/log.txt" && exec > >(tee "$GAMEDIR/log.txt") 2>&1

# Create directory for save files
CONFDIR="$GAMEDIR/conf/"
$ESUDO mkdir -p "${CONFDIR}"

# Mount Weston runtime
weston_dir=/tmp/weston
$ESUDO mkdir -p "${weston_dir}"
weston_runtime="weston_pkg_0.2"
if [ ! -f "$controlfolder/libs/${weston_runtime}.squashfs" ]; then
  if [ ! -f "$controlfolder/harbourmaster" ]; then
    pm_message "This port requires the latest PortMaster to run, please go to https://portmaster.games/ for more info."
    sleep 5
    exit 1
  fi
  $ESUDO $controlfolder/harbourmaster --quiet --no-check runtime_check "${weston_runtime}.squashfs"
fi
if [ "$PM_CAN_MOUNT" != "N" ](/binarycounter/Westonpack/wiki/-"$PM_CAN_MOUNT"-!=-"N"-); then
    $ESUDO umount "${weston_dir}"
fi
$ESUDO mount "$controlfolder/libs/${weston_runtime}.squashfs" "${weston_dir}"

cd $GAMEDIR
$GPTOKEYB "$game_executable" -c "$GAMEDIR/$gptk_filename" &

# Start Westonpack
# Put CRUSTY_SHOW_CURSOR=1 after "env" if you need a mouse cursor
$ESUDO env WRAPPED_LIBRARY_PATH=$game_libs \
$weston_dir/westonwrap.sh headless noop kiosk crusty_glx_gl4es \
XDG_DATA_HOME=$CONFDIR $GAMEDIR/$game_executable 

#Clean up after ourselves
$ESUDO $weston_dir/westonwrap.sh cleanup
if [ "$PM_CAN_MOUNT" != "N" ](/binarycounter/Westonpack/wiki/-"$PM_CAN_MOUNT"-!=-"N"-); then
    $ESUDO umount "${weston_dir}"
fi
pm_finish

Example Script (VirGL)

#!/bin/bash

# PortMaster preamble
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
if [ -d "/opt/system/Tools/PortMaster/" ]; then
  controlfolder="/opt/system/Tools/PortMaster"
elif [ -d "/opt/tools/PortMaster/" ]; then
  controlfolder="/opt/tools/PortMaster"
elif [ -d "$XDG_DATA_HOME/PortMaster/" ]; then
  controlfolder="$XDG_DATA_HOME/PortMaster"
else
  controlfolder="/roms/ports/PortMaster"
fi
source $controlfolder/control.txt
get_controls

# Adjust these to your paths
GAMEDIR=/$directory/ports/your_port_folder
game_executable="your_game.aarch64"
gptk_filename="YourControls.gptk"
game_libs=$GAMEDIR/libs.${DEVICE_ARCH}/:$LD_LIBRARY_PATH

# Logging
> "$GAMEDIR/log.txt" && exec > >(tee "$GAMEDIR/log.txt") 2>&1

# Create directory for save files
CONFDIR="$GAMEDIR/conf/"
$ESUDO mkdir -p "${CONFDIR}"

# Mount Weston runtime
weston_dir=/tmp/weston
$ESUDO mkdir -p "${weston_dir}"
weston_runtime="weston_pkg_0.2"
if [ ! -f "$controlfolder/libs/${weston_runtime}.squashfs" ]; then
  if [ ! -f "$controlfolder/harbourmaster" ]; then
    pm_message "This port requires the latest PortMaster to run, please go to https://portmaster.games/ for more info."
    sleep 5
    exit 1
  fi
  $ESUDO $controlfolder/harbourmaster --quiet --no-check runtime_check "${weston_runtime}.squashfs"
fi
if [ "$PM_CAN_MOUNT" != "N" ](/binarycounter/Westonpack/wiki/-"$PM_CAN_MOUNT"-!=-"N"-); then
    $ESUDO umount "${weston_dir}"
fi
$ESUDO mount "$controlfolder/libs/${weston_runtime}.squashfs" "${weston_dir}"

# Mount Mesa runtime
mesa_dir=/tmp/mesa
mesa_runtime="mesa_pkg_0.1"
if [ ! -f "$controlfolder/libs/${mesa_runtime}.squashfs" ]; then
    if [ ! -f "$controlfolder/harbourmaster" ]; then
        pm_message "This port requires the latest PortMaster to run, please go to https://portmaster.games/ for more info."
        sleep 5
        exit 1
    fi
    $ESUDO $controlfolder/harbourmaster --quiet --no-check runtime_check "${mesa_runtime}.squashfs"
fi
$ESUDO mkdir -p "${mesa_dir}"
if [ "$PM_CAN_MOUNT" != "N" ](/binarycounter/Westonpack/wiki/-"$PM_CAN_MOUNT"-!=-"N"-); then
    $ESUDO umount "${mesa_dir}"
fi
$ESUDO mount "$controlfolder/libs/${mesa_runtime}.squashfs" "${mesa_dir}"

cd $GAMEDIR
$GPTOKEYB "$game_executable" -c "$GAMEDIR/$gptk_filename" &

# Start Westonpack
# Put CRUSTY_SHOW_CURSOR=1 after "env" if you need a mouse cursor
$ESUDO env WRAPPED_LIBRARY_PATH=$game_libs \
$weston_dir/westonwrap.sh drm gl kiosk virgl \
XDG_DATA_HOME=$CONFDIR $GAMEDIR/$game_executable 

#Clean up after ourselves
$ESUDO $weston_dir/westonwrap.sh cleanup
if [ "$PM_CAN_MOUNT" != "N" ](/binarycounter/Westonpack/wiki/-"$PM_CAN_MOUNT"-!=-"N"-); then
    $ESUDO umount "${weston_dir}"
fi
pm_finish