Downloading and building examples
Guide how to download and build examples for the Magnum engine.
Contents
Examples demonstrate Magnum features, usage and capabilities. They are not needed for essential usage, but are useful for learning purposes in addition to the documentation itself.
Prepared packages
The easiest way to install Magnum Examples is to use one of the ready-made packages for your platform of choice. See Manual build if you want to have more control. Cross-compiling is very similar to cross-compiling of Magnum itself.
- ArchLinux packages
- Packages for Debian, Ubuntu and derivatives
- Gentoo Linux ebuilds
- Homebrew formulas for macOS
ArchLinux packages
In package/archlinux/magnum-examples-git
there is a package for Git development build. The package is also in AUR as The package is also in AUR as magnum-examples-git. It depends on Corrade, Magnum, Magnum Plugins, Magnum Integration and Magnum Extras ArchLinux packages.
There are also quite a few development packages for native builds or cross-compilation for Emscripten, Android and MinGW. See the PKGBUILD files in the package/archlinux
directory. They allow you to build and install the package directly from the source tree. Example usage:
git clone git://github.com/mosra/magnum-examples && cd magnum-examples cd package/archlinux makepkg -fp PKGBUILD # or any other PKGBUILD file
Once built, install the package using pacman
:
sudo pacman -U magnum-examples-*.pkg.tar.xz
Edit the PKGBUILDs if you want to pass additional flags to CMake or enable / disable additional features.
Packages for Debian, Ubuntu and derivatives
The package/debian/
directory contains all files needed for building Debian packages. You need Corrade, Magnum, Magnum Plugins, Magnum Integration and Magnum Extras Debian packages installed and in addition also the dpkg-dev
and debhelper
packages. Building is easy, just change directory to package root, link or copy the package/debian
directory there and run dpkg-buildpackage
:
git clone git://github.com/mosra/magnum-examples && cd magnum-examples ln -s package/debian . dpkg-buildpackage
This will compile binary and development packages, which will then appear in a parent directory. Install them using dpkg
:
sudo dpkg -i ../magnum-examples*.deb
If you want to pass additional flags to CMake or enable / disable additional features, add them to dh_auto_configure
at the bottom of debian/rules
. Watch out, as indentation has to be done using tabs, not spaces.
Gentoo Linux ebuilds
Gentoo Git ebuild is available in the package/gentoo
directory. Get the Corrade, Magnum, Magnum Plugins, Magnum Integration and Magnum Extras Gentoo packages first and then build and install Magnum Examples like this:
git clone git://github.com/mosra/magnum-examples && cd magnum-examples cd package/gentoo sudo ebuild dev-libs/magnum-examples/magnum-examples-99999.ebuild manifest clean merge
If you want to pass additional flags to CMake or enable / disable additional features, add them to mycmakeargs
in the *.ebuild
file.
Homebrew formulas for macOS
macOS Homebrew formulas building the latest Git revision are in the package/homebrew
directory. Either use the *.rb
files directly or use the tap at https:/
brew install mosra/magnum/magnum-examples
But often you may want to install the latest Git revision of all Magnum projects instead:
brew install --HEAD mosra/magnum/corrade brew install --HEAD mosra/magnum/magnum brew install --HEAD mosra/magnum/magnum-plugins brew install --HEAD mosra/magnum/magnum-integration brew install --HEAD mosra/magnum/magnum-extras brew install --HEAD mosra/magnum/magnum-examples
When installing from the *.rb
files you need to install the Corrade, Magnum, Magnum Plugins, Magnum Integration and Magnum Extras Homebrew packages first. If you want to pass additional flags to CMake or enable / disable additional features, edit the *.rb
file.
Manual build
The source is available on GitHub: https:/master
in order to keep the example code as simple as possible.
Enabling or disabling features
By default only the Triangle example is built. All examples depend on various libraries from the core Magnum repository and the Platform::
WITH_AREALIGHTS_EXAMPLE
– Build the Area lights example. Requires the Ui library and someTrueTypeFont
plugin.WITH_AUDIO_EXAMPLE
— Build the Audio example. Requires the Audio library and the StbVorbisAudioImporter plugin.WITH_BULLET_EXAMPLE
— Build the Bullet Physics example. Requires the BulletIntegration library.WITH_CUBEMAP_EXAMPLE
— Build the Cube map example. Requires the JpegImporter plugin, not available in OpenGL ES.WITH_LEAPMOTION_EXAMPLE
— Build the Leap Motion example.WITH_MOTIONBLUR_EXAMPLE
— Build the Motion blur example. Not available on OpenGL ES.WITH_OVR_EXAMPLE
— Build the Oculus VR example. Requires the OvrIntegration library.WITH_PICKING_EXAMPLE
— Build the Object picking example.WITH_PRIMITIVES_EXAMPLE
— Build the Primitives example.WITH_SHADOWS_EXAMPLE
— Build the Shadow map example.WITH_TEXT_EXAMPLE
— Build the Text rendering example. Requires the Text library and the FreeTypeFont plugin.WITH_TEXTUREDTRIANGLE_EXAMPLE
— Build the Textured triangle example. Requires the JpegImporter plugin, not available in OpenGL ES.WITH_TRIANGLE_EXAMPLE
— Build the Triangle example. Enabled by default.WITH_TRIANGLE_PLAIN_GLFW_EXAMPLE
— Build the Plain GLFW Triangle example. Depends on GLFW and a*Context
library for given platform.WITH_TRIANGLE_SOKOL_EXAMPLE
— Build the sokol_gfx Triangle example. Depends on GLEW. WITH_VIEWER_EXAMPLE
— Build the Viewer example. Requires the AnySceneImporter plugin.WITH_WEBVRE_EXAMPLE
— Build the WebVR example. Available only on Emscripten.
Besides building the whole project and enabling a particular subset of examples, it's also possible to build each example as if the example itself would be a project root. For example:
cd magnum-examples mkdir build-cubemap && cd build-cubemap cmake ../src/cubemap # ...
Building documentation
The documentation for examples is built as part of of the main Magnum documentation. Clone the projects next to each other and continue as described in Building documentation.
Continuous Integration
Travis
In package/ci/
there is a travis.yml
file with Linux GCC 4.7, macOS, Linux desktop GLES2/GLES3, iOS GLES2/GLES3, Emscripten WebGL1/WebGL2 and Android GLES2/GLES3 configuration. Online at https:/
AppVeyor
In package/ci/
there is an appveyor.yml
file with Windows desktop MSVC, MinGW, Windows desktop GLES2/GLES3 and Windows RT GLES2/GLES3 configuration. Online at https:/