May
09
2015

May 2015 updates to Magnum

IT

The Magnum C++11/C++14 and OpenGL graphics engine gained OpenGEX format support, a bunch of new importer plugins, cross-platform extension loader, transform feedback support and new features from OpenGL ES 3.1 and OpenGL 4.5, among other things. » pernament link

The new release comes almost a whole year after the previous one, mainly due to the fact that I'm currently full-time employed and I have less free time than I expected. Nevertheless the project accumulated quite a lot of changes over the year, so this changelog may be a bit overwhelming. I plan to do one smaller release in a few months to polish and clean up some more things and then I'll probably start breaking stuff in never-before-seen ways to make Vulkan support a reality.

The May 2015 snapshot is available under snapshot-2015-05 tag in Corrade, Magnum, Magnum Plugins, Magnum Integration and Magnum Examples GitHub repositories. This article will describe the most important changes, for all the commits that went to master branches since the June 2014 snapshot (tagged snapshot-2014-06) see logs in Corrade, Magnum, Magnum Plugins and Magnum Integration, respectively.

For compatibility branch there is tag snapshot-2015-05-compatibility in Corrade, Magnum, Magnum Plugins and Magnum Examples repositories.

Plugin aliases, smart importers and new format support

In an ongoing attempt to make the engine useful even without a slew of external library dependencies, I added a bunch of dependency-less plugins for loading common scene and image formats (see the changelog below for a complete list). I had a firsthand experience about how crazy hard it is to get working Freetype, HarfBuzz or even libPNG binary for Windows, so there are more plugins planned (especially for dependency-less font handling), stay tuned.

In addition to this, the plugin loader now supports aliases. It means that, to load PNG images, for example, you no longer need to worry about which particular plugin might be available on given platform and just always request PngImporter plugin:

PluginManager::Manager<Trade::AbstractImporter> manager{MAGNUM_PLUGINS_IMPORTER_DIR};
std::unique_ptr<Trade::AbstractImporter> importer = manager.loadAndInstantiate("PngImporter");
// ...

Now, if the PngImporter plugin is not available, it tries to load any other plugin that aliases with PngImporter. Currently it might be for example StbImageImporter, in future releases possibly also Sdl2ImageImporter or WebGlImageImporter.

Lastly, there are now smart image and scene loaders, named AnyImageImporter and AnySceneImporter. They try to detect file type from filename and then redirect the operation to dedicated importer plugin (so if you load image.tga, for example, it tries to load it with TgaImporter, if you load texture.png, it tries to load it with PngImporter etc.). In combination with plugin aliases this makes a fairly powerful importer framework.

Initial OpenDDL/OpenGEX support

Possibly the biggest new importer plugin is the OpenGEX format importer. If you haven't heard about it yet, it is a fairly new 3D scene file format based on the cleanly designed OpenDDL language. It aims to be a better alternative to the bloated XML-based COLLADA format and currently there are exporters from 3Ds Max, Maya and Blender.

Current OpenGEX importer implementation in Magnum covers the same feature set as the ColladaImporter plugin, but with faster and more robust implementation and hopefully with less bugs and uncovered corner cases. The future of the COLLADA importer is uncertain and it will probably be deprecated in favor of the new OpenGEX importer, because COLLADA support in 3D modelling software is far from ideal and the XML parser is hell to implement.

The underlying OpenDDL parser that powers the plugin is currently only a private part of the plugin, but if it is seen to be useful outside of the plugin, I may move it into a publicly usable library. Here's an example how OpenDDL file parsing can look like:

OpenDdl::Document d;
 
/* Parse the document */
if(!d.parse(data, OpenGex::structures, OpenGex::properties)) {
    // ...
}
 
/* Validate its structure */
if(!d.validate(OpenGex::rootStructures, OpenGex::structureInfo)) {
    // ...
}
 
/* Parse all meshes */
for(OpenDdl::Structure geometryObject: d.childrenOf(OpenGex::GeometryObject)) {
    /* Decide about primitive */
    if(std::optional<OpenDdl::Property> primitive = geometryObject.findPropertyOf(OpenGex::primitive)) {
        auto&& str = primitive->as<std::string>();
        if(str == "triangles") {
            // ...
        } else if(str == "lines") {
            // ...
        } // ...
    } else {
        // default primitive ...
    }
 
    /* Parse vertex array */
    OpenDdl::Structure vertexArray = geometryObject.firstChildOf(OpenGex::VertexArray);
    auto&& attrib = vertexArray.propertyOf(OpenGex::attrib).as<std::string>();
    if(attrib == "position") {
        // ...
    } else if(attrib == "normal") {
        // ...
    }
 
    /* Parse vertex array data */
    Containers::ArrayReference<const Float> vertexData = vertexArray.firstChild().asArray<Float>();
    // ...
}

The Viewer example was also updated to support loading OpenGEX files and it is now also available online through Emscripten.

New extension loader, extension loading for OpenGL ES

I was being more and more dissatisfied with the state of glLoadGen (which was originally mean to replace the even worse GLEW) and switched to flextGL. If you don't know it yet, it is very flexible and customizable extension loader generator and consists of just a single very clean Python file. Switching to it resulted in much shorter generated code (which means faster build times) and after a few minor changes I managed to add OpenGL ES support to it. So it is now finally possible to use extensions on both desktop GL and OpenGL ES. The only platforms which don't have any notion of traditional extension loading are WebGL and NaCl, on which the extension handling is not yet fully implemented.

OpenGL 4.5, OpenGL ES 3.1 support

In August 2014, OpenGL 4.5 was released, which was understood as some sort of a cleanup release with no radically new functionality. The most essential addition is ARB_direct_state_acccess, which finally cleans up some rough corners of the old EXT_direct_state_access extension and puts it in the core specification. Magnum currently implements both extensions and prefers the ARB one. Some API changes were needed to accomodate to the new design, mainly in construction of query objects and cube map texture data uploads. The other minor features include ability to query only a part of texture image, inverted conditional rendering etc., see below for complete list.

Thanks to the new extension loader it was also finally possible to implement OpenGL ES 3.1 support. Unlike the ES 2.0/3.0 switch, there is no compile-time option to enable OpenGL ES 3.1, the library is compiled for both 3.0 and 3.1 and the new features are enabled based on version reported by the driver.

IRC channel

In addition to all other communication channels there is now a IRC channel: join the discussion at #magnum-engine on Freenode.

Corrade

New features

Changes

Build system

  • CMake now always installs FindCorrade.cmake to library-specific location, making it usable without providing own copy of the file in depending projects. The WITH_FIND_MODULE option is no longer needed.
  • Displaying all header files, plugin metadata files and resource files in project view to make use of some IDEs less painful (such as QtCreator).
  • Gentoo ebuild (see GitHub Pull Request #16).

Bug fixes

  • Removed static initializers to avoid memory corruption in static builds (see GitHub Issue #90).
  • Plugin manager now correctly folows dependency order when unloading plugins.

Deprecated APIs

No API was deprecated in this release.

Removed APIs and features

  • Removed unused plugin replacement feature, as it had questionable benefits and no real use.
  • All functionality deprecated in January 2014 snapshot has been removed, namely:
    • Removed deprecated ability to use relative includes (e.g. #include <Utility/Debug.h>), use absolute paths (#include <Corrade/Utility/Debug.h>) instead.
    • Removed deprecated Utility::String::split() overload, use either split() or splitWithoutEmptyParts() instead.

Magnum

New features

Changes

  • Using flextGL instead of glLoadGen for OpenGL extension loading.
  • Platform::Sdl2Application now tries to create core context on all platforms, not just OSX (see GitHub Issue #80).
  • Buffer::bind(), Buffer::unbind() and Buffer::Target is now used for indexed buffer binding only.
  • Moved static binary operations from Math classes into free functions for more convenient usage (see GitHub Issue #74).
  • Better algorithm for comparing floating-point values.
  • Ensuring that all OpenGL objects are properly created before using them.
  • Using const char instead of const unsigned char for raw binary data.
  • Removed annoying restriction when adding reference-counted resources to ResourceManager.
  • Extension querying cleanup:
    • Removed APPLE_flush_buffer_range extension.
    • Replaced APPLE_vertex_array_object with ARB_vertex_array_object.
    • Replaced NV_half_float with ARB_half_float_vertex.
    • Replaced EXT_framebuffer_sRGB with ARB_framebuffer_sRGB.
  • Documentation cleanup, fixes and improvements.

Build system

  • CMake now always installs FindMagnum.cmake to library-specific location, making it usable without providing own copy of the file in depending projects. The WITH_FIND_MODULE option is no longer needed.
  • CMake now handles inter-library dependencies automatically without manually specifying each and every one (see GitHub Issue #73).
  • Ability to control static build of plugins separately using BUILD_PLUSING_STATIC.
  • Displaying all header files, plugin metadata files and resource files in project view to make use of some IDEs less painful (such as QtCreator).
  • Gentoo ebuild (see GitHub Pull Request #69).

Bug fixes

Deprecated APIs

Removed APIs and functionality

  • All functionality deprecated in January 2014 snapshot has been removed, namely:
    • Removed deprecated ability to use relative includes (e.g. #include <Mesh.h>), use absolute paths (#include <Magnum/Mesh.h>) instead.
    • Removed deprecated Mesh::Primitive enum, use MeshPrimitive instead.
    • Removed deprecated Sampler::maxAnisotropy() function, use Sampler::maxMaxAnisotropy() instead.
    • Removed deprecated Math::Geometry::Rectangle class, use Math::Range instead.
    • Removed deprecated SceneGraph::Animable::group() function, use SceneGraph::Animable::animables() instead.
    • Removed deprecated Shaders/magnumShadersResourceImport.hpp file, use Shaders/resourceImport.hpp instead.
    • Removed deprecated Text::TextRenderer alias, use Text::Renderer instead.
  • Removed long-deprecated BufferImage::setData() overload, use the other one instead.

Performance improvements

  • Faster vector multiplication in Math::Quaternion.
  • Saved one swizzle in Math::cross().
  • Allocation-free overloads of functions that took std::string just to pass its contents to OpenGL.

Magnum Plugins

New features

Removed APIs and functionality

  • All functionality deprecated in January 2014 snapshot has been removed, namely removed deprecated ability to use relative includes (e.g. #include <PngImporter/PngImporter.h>), use absolute paths (#include <MagnumPlugins/PngImporter/PngImporter.h>) instead.

Build system

  • CMake now always installs FindMagnumPlugins.cmake to library-specific location, making it usable without providing own copy of the file in depending projects. The WITH_FIND_MODULE option is no longer needed.
  • Displaying all header files, plugin metadata files and resource files in project view to make use of some IDEs less painful (such as QtCreator).
  • Gentoo ebuild (see GitHub Pull Request #5).

Magnum Integration

Build system

  • CMake now always installs FindMagnumIntegration.cmake to library-specific location, making it usable without providing own copy of the file in depending projects. The WITH_FIND_MODULE option is no longer needed.
  • Displaying all header files, plugin metadata files and resource files in project view to make use of some IDEs less painful (such as QtCreator).
  • Gentoo ebuild (see GitHub Pull Request #2).

Removed APIs and functionality

  • All functionality deprecated in January 2014 snapshot has been removed, namely removed deprecated ability to use relative includes (e.g. #include <BulletIntegration/Integration.h>), use absolute paths (#include <Magnum/BulletIntegration/Integration.h>) instead.

Deprecated APIs

No API was deprecated in this release.

Removed APIs

No deprecated API was removed in this release.

Magnum Examples

Changes

  • Reworked and simplified the Viewer example, updated it to work with virtually any file format.

Bug fixes

  • Removed unneeded requirement for ARB_invalidate_subdata from cubemap example (see GitHub Issue #63).

Build system

  • All examples are now installable in a way similar to Magnum itself.
  • Displaying all header files, plugin metadata files and resource files in project view to make use of some IDEs less painful (such as QtCreator).
  • Added ArchLinux, Debian and Gentoo packages (see GitHub Pull Request #8).

Magnum Bootstrap

No user-visible changes in this release, except for updates of CMake modules.


Jun
29
2014

June updates to Magnum

IT

The Magnum C++11 and OpenGL/OpenGL ES/WebGL graphics engine gained experimental Android support, windowless applications on OS X and Windows, uses SDL2 as the default toolkit, adds new texture and mesh features, improves build system and got huge documentation review. » pernament link

Mar
13
2014

How to draw a red square in Magnum — in one statement

IT

After reading the "How to draw a red square in Qt Quick" blog post showcasing the simplicity of Qt API I thought it would be interesting to try something similar in Magnum for comparison. » pernament link

Feb
14
2014
» Česky «

02/14/2014

Graphics

Happy Valentine's Day... » pernament link

Jan
21
2014

January updates to Magnum

IT

Since the previous October snapshot Magnum gained Visual Studio port, font conversion utility, improved text rendering along with example application, support for OpenGL debug output, documentation updates, better test coverage and many more usability improvements and fixes. » pernament link

Dec
11
2013

Reducing C++ compilation time in Magnum: code optimizations

IT

Large C++ projects often suffer with very long times for both full and incremental compilation, severely hurting productivity. The following series will overview some techniques employed in Magnum to make iteration times smaller, this article focuses on code-based optimizations. » pernament link

Oct
30
2013

October updates to Magnum

IT

Summary of changes during the first two months after public release. Two new ports, usability improvements, OpenGL limit queries and introduction of API deprecation. » pernament link

Oct
09
2013

Static and dynamic polymorphism in Magnum

IT

Thanks to generic programming and other features exclusive to C++ it is possible to handle polymorphism the most effective way for each use case. As a result, virtual calls are in Magnum used very sparingly. » pernament link

Sep
23
2013

C++11 features in Magnum: Simplifying daily workflow

IT

While the previous part was focused on C++11 features improving performance, here I will describe features which are used just to simplify your life by writing more concise code with less mistakes. » pernament link

Sep
08
2013

C++11 features in Magnum: Better memory management

IT

Regardless to what language you use, you always need to think about memory management. Garbage collectors might give you a sense that it's done automagically, but to get more performance you need to have control over heap usage in code running at 60 FPS. C++11 helps to avoid many heap allocations without sacrificing usability. » pernament link