Browse Source

Initial WebAssembly support.

pull/217/head
Vladimír Vondruš 9 years ago
parent
commit
a03f1f599c
  1. 2
      README.md
  2. 29
      doc/building.dox
  3. 1
      doc/changelog.dox
  4. 2
      doc/mainpage.dox
  5. 50
      package/archlinux/PKGBUILD-emscripten-wasm
  6. 51
      package/archlinux/PKGBUILD-emscripten-wasm-webgl2
  7. 2
      toolchains

2
README.md

@ -59,7 +59,7 @@ Platforms:
* **iOS** (through SDL2 toolkit) [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum) * **iOS** (through SDL2 toolkit) [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum)
* **Android** 2.3 (API Level 9) and higher [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum) * **Android** 2.3 (API Level 9) and higher [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum)
* **Windows RT** (Store/Phone) using ANGLE (through SDL2 toolkit) [![Build Status](https://ci.appveyor.com/api/projects/status/5b477m034cfaskse/branch/master?svg=true)](https://ci.appveyor.com/project/mosra/magnum/branch/master) * **Windows RT** (Store/Phone) using ANGLE (through SDL2 toolkit) [![Build Status](https://ci.appveyor.com/api/projects/status/5b477m034cfaskse/branch/master?svg=true)](https://ci.appveyor.com/project/mosra/magnum/branch/master)
* **HTML5/JavaScript** (through [Emscripten](https://github.com/kripken/emscripten/wiki)) [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum) * **Web** (asm.js or WebAssembly), through [Emscripten](http://kripken.github.io/emscripten-site/) [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum)
FEATURES FEATURES
======== ========

29
doc/building.dox

@ -485,13 +485,18 @@ make it available for depending projects.
@subsection building-cross-emscripten Crosscompiling for Emscripten @subsection building-cross-emscripten Crosscompiling for Emscripten
You will need [Emscripten](https://github.com/kripken/emscripten/wiki/Tutorial) You will need [Emscripten](http://kripken.github.io/emscripten-site/docs/getting_started/Tutorial.html)
installed and configured. installed and configured. The toolchains require CMake 3.7 or newer to properly
set compiler and linker flags.
Don't forget to adapt `EMSCRIPTEN_PREFIX` variable in `generic/Emscripten.cmake`
to path where Emscripten is installed. Default is `/usr/lib/emscripten`. There are two toolchain files. The `generic/Emscripten.cmake` is for the
Emscripten supports dynamic libraries only to simplify porting and they are classical (asm.js) build, the `generic/Emscripten-wasm.cmake` is for
generally slower, thus `BUILD_STATIC` is implicitly enabled. WebAssembly build. Don't forget to adapt `EMSCRIPTEN_PREFIX` variable in
`generic/Emscripten*.cmake` to path where Emscripten is installed; you can also
pass it explicitly on command-line using `-DEMSCRIPTEN_PREFIX`. Default is
`/usr/lib/emscripten`. Emscripten supports dynamic libraries only to simplify
porting and they are generally slower, thus `BUILD_STATIC` is implicitly
enabled.
Then create build directory and run cmake and build command in it. Be sure to Then create build directory and run cmake and build command in it. Be sure to
set `CMAKE_INSTALL_PREFIX` to path contained in `EMSCRIPTEN_TOOLCHAIN_PATH`. set `CMAKE_INSTALL_PREFIX` to path contained in `EMSCRIPTEN_TOOLCHAIN_PATH`.
@ -514,9 +519,13 @@ make it available for depending projects.
If you have Node.js installed, you can also build and run unit tests using If you have Node.js installed, you can also build and run unit tests using
`ctest`. See `BUILD_TESTS` above. `ctest`. See `BUILD_TESTS` above.
For ArchLinux there is also prepared package file in `package/archlinux`, For ArchLinux there are also prepared package files in `package/archlinux`,
named `PKGBUILD-emscripten`, see @ref building-packages-arch "above" for more named `PKGBUILD-emscripten`, `PKGBUILD-emscripten-webgl2`,
information. `PKGBUILD-emscripten-noopt`, `PKGBUILD-emscripten-noopt-webgl2`,
`PKGBUILD-emscripten-wasm` and `PKGBUILD-emscripten-wasm-webgl2`, see
@ref building-packages-arch "above" for more information. The first two are for
WebGL 1 / WebGL 2 optimized asm.js build (*slow* to compile), the second for
unoptimized build (faster to compile) and the third for WebAssembly build.
See @ref Platform::Sdl2Application documentation for more information about See @ref Platform::Sdl2Application documentation for more information about
building your projects for Emscripten. building your projects for Emscripten.

1
doc/changelog.dox

@ -46,6 +46,7 @@ namespace Magnum {
- ANGLE ES2/ES3 support, ability to create desktop GLES contexts on Windows - ANGLE ES2/ES3 support, ability to create desktop GLES contexts on Windows
- Windows Phone/Store support via ANGLE - Windows Phone/Store support via ANGLE
- iOS support - iOS support
- WebAssembly support when building for Emscripten
- WebGL 2.0 support - WebGL 2.0 support
- New OpenGL extension support: - New OpenGL extension support:
- @extension{EXT,draw_buffers} ES2 extension - @extension{EXT,draw_buffers} ES2 extension

2
doc/mainpage.dox

@ -83,7 +83,7 @@ Platforms:
- **iOS** (through SDL2 toolkit) - **iOS** (through SDL2 toolkit)
- **Android** 2.3 (API Level 9) and higher - **Android** 2.3 (API Level 9) and higher
- **Windows RT** (Store/Phone) using ANGLE (through SDL2 toolkit) - **Windows RT** (Store/Phone) using ANGLE (through SDL2 toolkit)
- **HTML5/JavaScript** (through [Emscripten](https://github.com/kripken/emscripten/wiki)) - **Web** (asm.js or WebAssembly), through [Emscripten](http://kripken.github.io/emscripten-site/)
@section mainpage-features Features @section mainpage-features Features

50
package/archlinux/PKGBUILD-emscripten-wasm

@ -0,0 +1,50 @@
# Author: mosra <mosra@centrum.cz>
pkgname=emscripten-magnum
pkgver=dev.wasm
pkgrel=1
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (Emscripten, wasm)"
arch=('any')
url="http://magnum.graphics"
license=('MIT')
depends=('emscripten-corrade')
makedepends=('cmake' 'emscripten' 'corrade' 'ninja')
options=('!strip' '!buildflags')
_rootdir=$startdir/../../
build() {
if [ ! -d "$_rootdir/build-emscripten-wasm" ] ; then
mkdir "$_rootdir/build-emscripten-wasm"
cd "$_rootdir/build-emscripten-wasm"
cmake .. \
-DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/Emscripten-wasm.cmake" \
-DCMAKE_PREFIX_PATH=/usr/lib/emscripten/system \
-G Ninja
fi
cd "$_rootdir/build-emscripten-wasm"
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/lib/emscripten/system \
-DWITH_AUDIO=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_OBJIMPORTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DBUILD_TESTS=ON
ninja
}
check() {
cd "$_rootdir/build-emscripten-wasm"
CORRADE_TEST_COLOR=ON ctest --output-on-failure -E ALTest
}
package() {
cd "$_rootdir/build-emscripten-wasm"
DESTDIR="$pkgdir/" ninja install
}

51
package/archlinux/PKGBUILD-emscripten-wasm-webgl2

@ -0,0 +1,51 @@
# Author: mosra <mosra@centrum.cz>
pkgname=emscripten-magnum
pkgver=dev.wasm.webgl2
pkgrel=1
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (Emscripten WebGL 2.0, wasm)"
arch=('any')
url="http://magnum.graphics"
license=('MIT')
depends=('emscripten-corrade')
makedepends=('cmake' 'emscripten' 'corrade' 'ninja')
options=('!strip' '!buildflags')
_rootdir=$startdir/../../
build() {
if [ ! -d "$_rootdir/build-emscripten-wasm-webgl2" ] ; then
mkdir "$_rootdir/build-emscripten-wasm-webgl2"
cd "$_rootdir/build-emscripten-wasm-webgl2"
cmake .. \
-DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/Emscripten-wasm.cmake" \
-DCMAKE_PREFIX_PATH=/usr/lib/emscripten/system \
-G Ninja
fi
cd "$_rootdir/build-emscripten-wasm-webgl2"
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/lib/emscripten/system \
-DTARGET_GLES2=OFF \
-DWITH_AUDIO=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_OBJIMPORTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DBUILD_TESTS=ON
ninja
}
check() {
cd "$_rootdir/build-emscripten-wasm-webgl2"
CORRADE_TEST_COLOR=ON ctest --output-on-failure -E ALTest
}
package() {
cd "$_rootdir/build-emscripten-wasm-webgl2"
DESTDIR="$pkgdir/" ninja install
}

2
toolchains

@ -1 +1 @@
Subproject commit 1e2799dc30540b5d0a90395d654aec63116e9d6e Subproject commit 5f1b09a6f953a375e03991b2b408175d13f20888
Loading…
Cancel
Save