Skip to content

Emscripten #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8fdfe31
sdl2
revmischa Nov 13, 2015
22d85ae
SDL
revmischa Nov 13, 2015
1c31c3e
disabling cmake building of emscripten project for now because it's a…
revmischa Nov 14, 2015
e0c46af
note on how 2 compile emscripten project
revmischa Nov 14, 2015
0fcbd6a
emscript compile working kinda
revmischa Nov 14, 2015
82d0220
Merge branch 'master' into emscripten
revmischa Mar 7, 2018
65fea32
merge master
revmischa Jan 19, 2020
db3f8a3
making emscripten configure more automatic. having compilation issue …
revmischa Jan 19, 2020
468b5db
no more cmake
revmischa Jan 19, 2020
74ceb84
markdown
revmischa Jan 19, 2020
e2445ad
travis
revmischa Jan 19, 2020
0bef048
travis
revmischa Jan 19, 2020
3040f92
travis
revmischa Jan 19, 2020
24d4ff6
don't build LLVM JIT for emscripten
revmischa Jan 19, 2020
0d8e937
don't build -sdl -test for emscripten
revmischa Jan 19, 2020
8652046
let's try -sdl
revmischa Jan 19, 2020
1340479
Merge branch 'master' into emscripten
revmischa Jan 19, 2020
5216b0b
readme
revmischa Jan 27, 2020
7e69d13
Emscripten WIP
revmischa May 2, 2020
6e1713b
Merge branch 'emscripten' of github.com:projectM-visualizer/projectm …
revmischa May 2, 2020
40aac06
Merge branch 'emscripten' of github.com:projectM-visualizer/projectm …
revmischa Apr 10, 2021
074729d
mergee
revmischa Apr 10, 2021
93c1b5e
readme
revmischa Apr 10, 2021
79ae7ef
working towards being able to build projectM with emscripten (updating)
revmischa Apr 10, 2021
bb66c0f
can at least build+run emscripten version now, shaders need fixing
revmischa Apr 10, 2021
d55f98c
kinda works
revmischa Apr 10, 2021
ac61def
clean
revmischa Apr 10, 2021
e5130fe
bleh
revmischa Apr 10, 2021
d67288c
bleh
revmischa Apr 10, 2021
7229b60
bleh
revmischa Apr 10, 2021
6224938
GL
revmischa Apr 10, 2021
a9b7d4d
emscripten docker
revmischa Apr 10, 2021
391d009
bleh
revmischa Apr 10, 2021
5529fd9
bleh
revmischa Apr 10, 2021
fe6bb75
bleh
revmischa Apr 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
build_logs/

xcuserdata
src/libprojectM/config.inp
src/libprojectM/config.inp.b
Expand Down
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ matrix:
env:
- MATRIX_EVAL="brew update && brew install sdl2"

# emscripten
- os: linux
env: >
MATRIX_EVAL="docker run -dit
-v $(pwd):/src
--name emscripten
emscripten/emsdk
bash"
services:
- docker
script:
- docker exec -it emscripten emconfigure ./configure
- docker exec -it emscripten emmake make


notifications:
email:
on_success: never
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Its purpose in life is to read an audio input and to produce mesmerizing visuals
* [Source code](https://github.com/projectM-visualizer/projectm/)
* [Qt5](https://www.qt.io/)-based [PulseAudio](https://www.freedesktop.org/wiki/Software/PulseAudio/) and JACK desktop apps in [source code](https://github.com/projectM-visualizer/projectm/)
* [ALSA, XMMS, Winamp, JACK](https://sourceforge.net/projects/projectm/files/) (source, unmaintained)
#### Experimental / In-Progress
* [Web+Emscripten](src/projectM-emscripten/README.md)
* [Gstreamer](https://github.com/projectM-visualizer/projectm/pull/207)

### Discord chat
[Chat with us on Discord.](https://discord.gg/tpEuywB)
Expand Down
31 changes: 21 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,25 @@ AC_LANG(C++)
AC_CONFIG_MACRO_DIRS([m4 m4/autoconf-archive])

dnl emscripten
AC_ARG_ENABLE([emscripten],
AS_HELP_STRING([--enable-emscripten], [Build for web with emscripten]),
[], [enable_emscripten=no])
AS_IF([test "x$enable_emscripten" = "xyes" || test "x$EMSCRIPTEN" = "xyes"], [
m4_include([m4/emscripten.m4])
AM_EMSCRIPTEN # set emscripten_compiler=yes/no
AC_MSG_CHECKING(Emscripten enabled)
AC_MSG_RESULT("$emscripten_compiler")
AS_IF([test "x$emscripten_compiler" = "xyes"], [
dnl Set up emscripten
m4_include([m4/emscripten.m4])
AC_DEFINE([EMSCRIPTEN], [1], [Define EMSCRIPTEN])
enable_threading=no
AC_DEFINE([ENABLE_EMSCRIPTEN], [1], [Build projectM-emscripten])
enable_gles=yes
enable_sdl=yes
enable_llvm=no
enable_preset_subdirs=no
enable_threading=no
enable_qt=no
dnl Enable SDL2 and WEBGL2 (OpenGL ES 3)
EMSCRIPTEN_FLAGS="-g -lgl -s ALLOW_MEMORY_GROWTH=1 -s USE_SDL=2 -s USE_WEBGL2=1 -s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2 -O3"
AC_SUBST([EMSCRIPTEN_FLAGS])
CFLAGS="$CFLAGS $EMSCRIPTEN_FLAGS"
CXXFLAGS="$CXXFLAGS $EMSCRIPTEN_FLAGS"
], [
dnl Running in a normal OS (not emscripten)
AX_CHECK_GL
Expand Down Expand Up @@ -86,7 +95,7 @@ AC_CONFIG_FILES([

# SDL
AC_ARG_ENABLE([sdl], AS_HELP_STRING([--enable-sdl], [Build SDL2 application]), [], [enable_sdl=check])
AS_IF([test "$enable_sdl" != "no"], [
AS_IF([test "$enable_sdl" != "no" && test "x$emscripten_compiler" != "xyes"], [
PKG_CHECK_MODULES([SDL], [sdl2], [
m4_include([m4/sdl2.m4])
SDL_VERSION="2.0.5"
Expand All @@ -105,6 +114,7 @@ AS_IF([test "$enable_sdl" != "no"], [
])
])

AM_CONDITIONAL([ENABLE_TEST], [test "$enable_sdl" = "yes"])

# Threading
AC_ARG_ENABLE([threading],
Expand Down Expand Up @@ -223,7 +233,7 @@ AM_CONDITIONAL([ENABLE_SDL], [test "x$enable_sdl" = "xyes"])
AM_CONDITIONAL([ENABLE_QT], [test "x$enable_qt" = "xyes"])
AM_CONDITIONAL([ENABLE_JACK], [test "x$enable_jack" = "xyes"])
AM_CONDITIONAL([ENABLE_PULSEAUDIO], [test "x$enable_pulseaudio" = "xyes"])
AM_CONDITIONAL([ENABLE_EMSCRIPTEN], [test "x$enable_emscripten" = "xyes"])
AM_CONDITIONAL([ENABLE_EMSCRIPTEN], [test "x$emscripten_compiler" = "xyes"])


my_CFLAGS="-Wall -Wchar-subscripts -Wformat-security -Wpointer-arith -Wshadow -Wsign-compare -Wtype-limits"
Expand All @@ -236,7 +246,8 @@ AC_SUBST([my_CFLAGS])

# glm (vendored, this should never fail; headers are in vendor/glm)
AC_SUBST(CPPFLAGS, "$CPPFLAGS -I${srcdir}/vendor")
AS_IF([test "x$enable_emscripten" != "xyes"], [
AC_MSG_RESULT($emscripten_compiler)
AS_IF([test "x$emscripten_compiler" != "xyes"], [
AC_CHECK_HEADER([glm/glm.hpp],, AC_MSG_ERROR(vendored libglm not found.))
])

Expand Down Expand Up @@ -270,6 +281,6 @@ Qt: ${enable_qt}
Pulseaudio: ${enable_pulseaudio}
Jack: ${enable_jack}
OpenGLES: ${enable_gles}
Emscripten: ${enable_emscripten}
Emscripten: ${emscripten_compiler}
LLVM JIT: ${enable_llvm}
])
20 changes: 6 additions & 14 deletions src/projectM-emscripten/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
AM_CPPFLAGS = \
${my_CFLAGS} \
-include $(top_builddir)/config.h \
-I$(top_builddir)/config.h \
-I$(top_builddir)/vendor \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-I${top_srcdir}/src/libprojectM \
-I${top_srcdir}/src/libprojectM/Renderer \
${SDL_CFLAGS}

EMSCRIPTEN_FLAGS = -s USE_SDL=2 -s USE_WEBGL2=1
# -s WASM=0

bin_PROGRAMS = projectW.bc
projectW_bc_SOURCES = ../libprojectM/KeyHandler.cpp projectM_SDL_emscripten.cpp
projectW_bc_LDADD = ${SDL_LIBS} ${top_srcdir}/src/libprojectM/libprojectM.la
projectW_bc_LDFLAGS = $(EMSCRIPTEN_FLAGS) -static
projectW_bc_PROGRAM = projectW.bc

projectW.html: generate-html

generate-html:
emcc -s ALLOW_MEMORY_GROWTH=1 $(EMSCRIPTEN_FLAGS) projectW.bc -o projectW.html
projectW.html: projectM_SDL_emscripten.cpp Makefile.am
emcc -s $(EMSCRIPTEN_FLAGS) $(AM_CPPFLAGS) ${top_srcdir}/src/libprojectM/.libs/libprojectM.a \
../libprojectM/KeyHandler.cpp projectM_SDL_emscripten.cpp \
-o projectW.html

run: projectW.html
emrun --browser chrome projectW.html
emrun projectW.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Running on the web.
* On fresh repositories: `./autogen.sh`

## Compile
* `emconfigure ./configure --enable-emscripten`
* `emconfigure ./configure`
* `emmake make`

## Create wasm & html files
Expand Down
Binary file not shown.
Binary file added src/projectM-emscripten/lib/libRenderer.a
Binary file not shown.
Binary file added src/projectM-emscripten/lib/libprojectM.a
Binary file not shown.
Loading