-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL.raspi
131 lines (105 loc) · 5.5 KB
/
INSTALL.raspi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# NOTICE THIS IS NOT A SHELL SCRIPT JUST YET.
# It's a step-by-step instruction guide.
# You're going to have to do some manual tuning in a few places.
# Maybe if I put enough sed/patch commands in here I can make it a script,
# but right now it isn't.
#
# I don't have any raspberry pi hardware so I followed the instructions here:
# https://linuxconfig.org/how-to-run-the-raspberry-pi-os-in-a-virtual-machine-with-qemu-and-kvm
# This means I'm using the Raspberry Pi OS image at:
# wget https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-01-12/2021-01-11-raspios-buster-armhf-lite.zip
# ... with one difference:
# I downloaded the -full instead of the -lite image.
# This may be why a few of the apt libraries that I needed were already installed, maybe not, I don't know.
# Another note: The `virt-install` command on this page now needs one extra argument to run correctly: `--os-variant=debian9`.
# First we pick somewhere to download all repos. I picked home.
cd
# I'm putting all the repos etc into the `Projects` folder.
# Feel free to change this to whatever dir you want.
# Replace `$HOME/Projects/` in the line below accordingly:
mkdir Project
echo 'export LUA_PATH=";;$HOME/Projects/?.lua;$HOME/Projects/?/?.lua"' >> .bashrc
# then you'll have to either restart your shell, or run the command:
export LUA_PATH=";;$HOME/Projects/?.lua;$HOME/Projects/?/?.lua"
# then cd into that location
cd Project
# git all repos
git clone https://github.com/thenumbernine/sand-attack sand-attack
git clone https://github.com/thenumbernine/lua-template template
git clone https://github.com/thenumbernine/lua-ext ext
git clone https://github.com/thenumbernine/lua-ffi-bindings ffi
git clone https://github.com/thenumbernine/vec-ffi-lua vec-ffi
git clone https://github.com/thenumbernine/lua-matrix matrix
git clone https://github.com/thenumbernine/lua-image image
git clone https://github.com/thenumbernine/lua-gl gl
git clone https://github.com/thenumbernine/lua-glapp glapp
git clone https://github.com/thenumbernine/lua-imgui imgui
git clone https://github.com/thenumbernine/lua-imguiapp imguiapp
git clone https://github.com/thenumbernine/lua-audio audio
# install apt packages
# these were already installed for me in raspberry pi os:
#sudo apt install luajit
#sudo apt install libgles2-mesa
#sudo apt install libsdl2-2.0-0
#sudo apt install libvorbisfile3
#sudo apt install libopenal1
# Raspberry pi /usr/lib/arm-linux-gnueabihf/ doesn't like putting .so extension symlinks to the .so.<version> files.
# So from here on out we will have to hack in the specific library names for luajit to link to them.
# (Alternatively you can just add those symlinks yourself and then you won't have to change anything.)
# You should be able to run the test_es.lua script in glapp/tests using the following lengthy command (which will override the .so names to point to the names in Raspberry Pi):
luajit -e "require'ffi.load'.GLESv2='libGLESv2.so.2' require'ffi.load'.SDL2='libSDL2-2.0.so.0" test_es.lua
# ... and you should see a spinning triangle.
# Now we have to accomodate luajit's dynamic linking to .so files by specifying the exact names.
# Put the following lines at the top of sand-attack/run.lua:
# (Put them immediately after line 1 which contains the # with luajit command used to launch sand-attack.)
require 'ffi.load'.GLESv2 = 'libGLESv2.so.2'
require 'ffi.load'.SDL2 = 'libSDL2-2.0.so.0'
require 'ffi.load'.openal = 'libopenal.so.1'
require 'ffi.load'.vorbisfile = 'libvorbisfile.so.3'
# Alternatively if you want these library redirections to work for multiple projects, you can add the following keys to the table in the file ffi/load.lua:
# (but this is not necessary with the modified sand-attack/run.lua)
GLESv2 = 'libGLESv2.so.2',
SDL2 = 'libSDL2-2.0.so.0',
openal = 'libopenal.so.1',
vorbisfile = 'libvorbisfile.so.3',
# now the hard part: cimgui
# first, cimgui's prereq: SDL headers:
# SDL2 runtime was already installed for me,
# but building cimgui is going to need SDL2 headers, which were not installed:
# so I tried `sudo apt install libsdl2-dev`
# ... but this got me some 404 Not Found errors with the Raspberry Pi repos
# ... so instead I copied the headers by hand ...
# seems cimgui appreciates it if you use the same include as the installed libSDL2.so, which for me is 2.0.9
wget https://sourceforge.net/projects/libsdl/files/SDL/2.0.9/SDL2-2.0.9.zip/download
unzip somewhere
cd somewhere
./configure
# ... to get SDL_config.h correct
cd ..
# even if configure errors and complains you're missing something, no worries, we just need the headers, not to build the binaries.
# now for cimgui itself:
git clone https://github.com/cimgui/cimgui
cd cimgui
git checkout tags/1.89.7dock
git submodule update --init --recursive
# now change the Makefile in cimgui:
# apply these changes to the Makefile in the cimgui base folder:
OBJS += ./imgui/backends/imgui_impl_sdl2.o
OBJS += ./imgui/backends/imgui_impl_opengl3.o
CXXFLAGS += -DIMGUI_IMPL_API=extern\ \"C\"
CXXFLAGS += -Iwherever/you/put/the/SDL2/include
# make sure loading cimgui loads SDL2 as well.
# I could also put this as a ffi.load somewhere in the ffi/cimgui.lua file but meh.
CXXFLAGS += /usr/lib/arm-linux-gnueabihf/libSDL2-2.0.so.0
OUTPUTNAME = libcimgui_sdl.so
# then build:
make all
# then copy to sand-attack, or wherever ffi.load can find it
# (could also be wherever LD_LIBRARY_PATH points)
cp libcimgui_sdl.so ../sand-attack/
cd ..
# finally we can run it:
cd sand-attack/
# let luajit know where to look for libcimgui_sdl.so
export LD_LIBRARY_PATH=.
luajit run.lua