See tips from https://github.com/floooh/sokol-samples#how-to-build-without-a-build-system
git clone https://github.com/floooh/sokol-samples
git clone https://github.com/floooh/sokol
git clone https://github.com/floooh/sokol-tools-bin
git clone https://github.com/ocornut/imgui.git
cd imgui
git checkout v1.91.9b
cd ..
git clone https://github.com/epezent/implot.git
git clone https://github.com/nlohmann/json.git
# Make sure to install emscripten as appropriate
sudo pacman -S emscripten
# or
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
cd ..
source emsdk/emsdk_env.sh
# or source emsdk_env.fish
#clone this gist
git clone https://gist.github.com/digitalsignalperson/c935e377e407e0173ac40562039380bf.git imgui-endpoint-demo
cd sokol-samples/sapp
../../sokol-tools-bin/bin/linux/sokol-shdc -i cube-sapp.glsl -o cube-sapp.glsl.h -l glsl300es
/usr/lib/emscripten/emcc cube-sapp.c ../libs/sokol/sokol.c -o cube-sapp.html -DSOKOL_GLES3 -I../../sokol -I../libs -sUSE_WEBGL2 --shell-file=../webpage/shell.html
/usr/lib/emscripten/emrun cube-sapp.html
/usr/lib/emscripten/emcc imgui-sapp.cc ../libs/sokol/sokol.cc \
../../imgui/imgui.cpp \
../../imgui/imgui_demo.cpp \
../../imgui/imgui_draw.cpp \
../../imgui/imgui_tables.cpp \
../../imgui/imgui_widgets.cpp \
-o imgui-sapp.html \
-DSOKOL_GLES3 \
-I../../sokol \
-I../../imgui \
-I../../sokol/util \
-I../libs \
-sUSE_WEBGL2 \
--shell-file=../webpage/shell.html
/usr/lib/emscripten/emrun imgui-sapp.html
Write a simple endpoing using python and flask to serve some data for a scatter plot. Modify imgui-sapp.cc to include sokol_fetch.h to get the data from the endpoint. Modify imgui-sapp.cc to draw a scatter plot using implot
Make sure sokol_fetch.h
include is enabled here
sed -i '/#include "sokol_fetch.h"/s|^//||' sokol-samples/libs/sokol/sokol.cc
And patch imgui-sapp.cc
with this modded demo
cp ../../imgui-endpoint-demo/imgui-endpoint-viewer-sapp.cc imgui-sapp.cc
Now build
/usr/lib/emscripten/emcc imgui-sapp.cc ../libs/sokol/sokol.cc \
../../imgui/imgui.cpp \
../../imgui/imgui_demo.cpp \
../../imgui/imgui_draw.cpp \
../../imgui/imgui_tables.cpp \
../../imgui/imgui_widgets.cpp \
../../implot/implot.cpp \
../../implot/implot_items.cpp \
-o imgui-endpoint-viewer-sapp.html \
-DSOKOL_GLES3 \
-I../../sokol \
-I../../imgui \
-I../../implot \
-I../../json/single_include \
-I../../sokol/util \
-I../libs \
-sUSE_WEBGL2 \
-sFETCH \
--shell-file=../webpage/shell.html
Run the server and the client
python ../../imgui-endpoint-demo/server.py
/usr/lib/emscripten/emrun imgui-endpoint-viewer-sapp.html
To build a naive executable instead:
g++ imgui-sapp.cc ../libs/sokol/sokol.cc \
../../imgui/imgui.cpp \
../../imgui/imgui_demo.cpp \
../../imgui/imgui_draw.cpp \
../../imgui/imgui_tables.cpp \
../../imgui/imgui_widgets.cpp \
../../implot/implot.cpp \
../../implot/implot_items.cpp \
-o imgui-sapp \
-I../../sokol \
-I../../imgui \
-I../../implot \
-I../../json/single_include \
-I../../sokol/util \
-I../libs \
-DSOKOL_GLCORE \
-lGL -ldl -lX11 -lXi -lXcursor -lasound -pthread \
-std=c++17 \
-Wall -Wextra
./imgui-sapp