Magnum Graphics Middleware

repository·master·Indexed 26 days ago

https://github.com/mosra/magnum

A lightweight, modular C++11 graphics middleware for games and data visualization. It provides graphics abstraction and platform independence across Linux, Windows, macOS, iOS, Android, and Web (via Emscripten). Magnum supports OpenGL 2.1 through 4.6, OpenGL ES 2.0 and 3.0–3.2, and WebGL 1.0 and 2.0. The ecosystem includes related projects such as Corrade, Magnum Plugins, and Magnum Integration.

Tokens
1.7K
Snippets
0
Records
19
Agent score
90%

What's inside Magnum

  1. Explore Magnum ecosystem and related projects

    master

    Magnum is a modular engine. Additional functionality is often provided in separate repositories to keep the core engine small:

    • Corrade: The main dependency of Magnum; a multiplatform utility library.
    • Magnum Bootstrap: Bootstrap projects for various use cases to help you get running quickly.
    • Magnum Plugins: Importer plugins for image, font, audio, and 3D model formats.
    • Magnum Integration: Integrations with external math and physics libraries.
    • Magnum Examples: A collection of usage examples ranging from 'Hello World' to complex 3D model viewers.
    • Magnum Extras: A playground for testing new APIs and specialized functionality.
    • Magnum Bindings: Language bindings (e.g., Python).
    • Magnum Singles: Single-header versions of Magnum functionality for easy integration.
  2. Get started with Magnum

    master

    To begin using Magnum in your project, follow the official guide for downloading, building, installing, and starting usage: https://doc.magnum.graphics/magnum/getting-started.html.

    For detailed instructions on the build process, refer to the building documentation: https://doc.magnum.graphics/magnum/building.html.

    Once installed, you can explore the library through:

  3. Use Magnum as single-header libraries

    master
    If you want to avoid build system complexity, you can use various Magnum functionalities as single-header libraries. Simply download the required file, #include it in your project, and it is ready to use without additional build system wrangling.
  4. Compare in-memory images to files with CompareImageToFile

    master

    Use Magnum::DebugTools::CompareImageToFile to compare an in-memory image to an image file. This is a combination of CompareImage and CompareImageFile.

    Like CompareImageFile, it supports the --save-diagnostic option to save the actual image data to a file upon failure.

  5. Compare images against files with CompareImageFile

    master

    Use Magnum::DebugTools::CompareImageFile to compare an in-memory image against an image loaded from a file. This requires a Trade::AbstractImporter plugin manager to load the file.

    If the comparison fails and the --save-diagnostic option is used with the Corrade::TestSuite::Tester, the actual image data will be saved to the specified directory using the Trade::AnyImageConverter plugin.

  6. Compare in-memory images with CompareImage

    master

    Use Magnum::DebugTools::CompareImage to compare two in-memory images (e.g., Magnum::ImageView2D) for equality. Since real-world images often have slight variations due to hardware or compression, you can provide maxThreshold (maximum delta for a single pixel) and meanThreshold (average delta over all pixels) to allow for controlled differences.

    In a Corrade::TestSuite, use CORRADE_COMPARE_AS() for exact bit-equality or CORRADE_COMPARE_WITH() to specify thresholds.

  7. Supported platforms and graphics APIs for Magnum

    master

    Magnum provides graphics abstraction and platform independence across the following environments:

    Supported Platforms:

    • Linux and embedded Linux
    • Windows (MSVC, clang-cl, MinGW, and Windows RT/Store/Phone)
    • macOS and iOS
    • Android
    • Web (via Emscripten using asm.js or WebAssembly)

    Supported Graphics APIs:

    • OpenGL 2.1 through 4.6 (including core profile and modern extensions)
    • OpenGL ES 2.0, 3.0–3.2 (with extensions matching desktop OpenGL)
    • WebGL 1.0 and 2.0 (with extensions matching desktop OpenGL)
  8. Replace deprecated ObjectRenderer with Primitives::axis

    master
    The Magnum::DebugTools::ObjectRenderer, ObjectRenderer2D, and ObjectRenderer3D classes are deprecated. Instead of using these debug tools to visualize object position, rotation, and scale, you should use Magnum::Primitives::axis2D() or Magnum::Primitives::axis3D() within a custom SceneGraph::Drawable.
  9. Compare arbitrary pixel views

    master

    You can use Corrade::Containers::StridedArrayView2D containing raw pixel data (e.g., from ImageView::pixels()) as the 'actual' input for CompareImage and CompareImageToFile. This allows for flexible comparisons, such as comparing flipped pixel data or sliced channels (e.g., comparing RGB data from a 4-component framebuffer against a 3-component ground truth).

    The pixel format is automatically detected from the type of the view (e.g., Magnum::Vector3ub).

  10. Compare material data in Corrade TestSuite

    master

    Use Magnum::DebugTools::CompareMaterial to compare two Magnum::Trade::MaterialData instances within a Corrade::TestSuite. The comparator detects differences in material type, layer count, attributes, and attribute values.

    When a comparison fails, it provides detailed output via printMessage describing the specific differences (e.g., different attribute types or mismatched values). It supports all Magnum::Trade::MaterialAttributeType values.

  11. Corrade::TestSuite::Comparator specialization for CompareMaterial

    master

    The Corrade::TestSuite::Comparator<Magnum::DebugTools::CompareMaterial> specialization provides the following interface for material comparison:

    • ComparisonStatusFlags operator()(const Magnum::Trade::MaterialData& actual, const Magnum::Trade::MaterialData& expected): Compares two material data instances and returns the status flags.
    • void printMessage(ComparisonStatusFlags flags, Utility::Debug& out, Containers::StringView actual, Containers::StringView expected) const: Prints a detailed description of the differences between the actual and expected materials to the provided debug output.