Examples

Learn by example to get quickly up to speed.

The examples assume that you have at least basic knowledge about graphics (what are homogeneous coordinates, what is mesh, vertex, texture...), how GPU APIs work (what are buffers, what is depth test for...) and basics of GLSL (attributes, uniforms, vertex/fragment shaders...). Deep knowledge of OpenGL / Vulkan APIs themselves is not required, as Magnum wraps most of the functionality in its own classes.

Full source code for all examples is available in the GitHub repository, see Downloading and building examples for more information. The ports branch contains additional patches for mobile and web platform support that aren't present in master in order to keep the example code as simple as possible.

Fully documented tutorials

The following examples explain the basic principles and have fully documented tutorials:

Image Your first triangle live web demo
Basic rendering with builtin shaders.
Image Primitives live web demo
Importing mesh data, 3D transformations and input handling.
Image Textured triangle live web demo
Importing image data, texturing and custom shaders.
Image Model viewer live web demo
Scene graph, resource management and model importing.
Image Triangle using plain GLFW
Shows how to use Magnum with custom platform integration APIs.
Image Triangle using sokol_gfx
Shows how to use custom renderers with Magnum.

Other examples

The following consist of documented source code only:

Image Area lights live web demo
Basic real-time area lights.
Image Audio sound live web demo
Shows how to play spatialized audio with Magnum.
Image Box2D physics live web demo
A simple example using the Box2D physics library.
Image Bullet Physics physics live web demo
Integration of Bullet Physics into Magnum.
Image Cube map
Demonstrates usage of cube map textures and texture blending.
Image Leap Motion vr
Integration of the LeapMotion SDK into Magnum.
Image Motion blur
Accumulates multiple frames together to create a motion blur effect.
Image Mouse Interaction live web demo
Advanced depth-aware mouse interaction for navigating a scene.
Image Object picking live web demo
Usage of multiple framebuffer attachments to implement object picking.
Image Shadow map
Showcases the Parallel Split / Cascade shadow mapping technique.
Image Text rendering live web demo
Showcase of Magnum distance-field text rendering.
Image Triangle using Vulkan vulkan
Directly using Vulkan with hand-written SPIR-V to produce a triangle offscreen.
Image Oculus VR vr
Integration of the Oculus SDK into Magnum.
Image WebVR vr live web demo
Basic WebVR application.

There are also examples for the Corrade library itself.

While Magnum itself and its documentation is licensed under the MIT/Expat license, all example code is put into public domain (or UNLICENSE) to free you from any legal obstacles when reusing the code in your apps:

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/