Coin 3D Graphics Library

repository·master·Indexed 18 days ago

https://github.com/coin3d/coin

An OpenGL-based, open-source C++ class library that implements the Open Inventor 2.1 API. Coin uses a scene graph-based, retained mode approach for 3D visualization and model manipulation, featuring support for GLSL shaders, 3D sound, and VRML97. It includes the coin-config utility for managing build and installation information, and provides tools for configuring rendering via SoRenderManager and application settings via SoConfigSettings.

Tokens
4.4K
Snippets
22
Records
29
Agent score
63%

What's inside Coin

  1. Overview of Coin

    master

    Coin is an OpenGL-based, 3D graphics library that implements the Open Inventor 2.1 API. It is a scene graph based, retained mode, C++ class library designed for 3D visualization and model manipulation.

    Key features include:

    • Compatibility with Open Inventor 2.1 API.
    • Support for GLSL shaders.
    • 3D sound support.
    • Support for file formats like VRML97.
    • Optimized OpenGL rendering techniques.

    Coin is the core component of the larger 'Coin3D' library group.

  2. Understand Coin binary compatibility and versioning

    master

    Coin uses a three-digit versioning system (Major.Minor.Micro) to manage API and ABI compatibility:

    • Patch releases (same Major and Minor): e.g., 1.2.3 to 1.2.4. These are binary compatible and contain only bugfixes, documentation, or packaging updates.
    • Minor releases (same Major): e.g., 3.0.1 to 3.1.0. These are upwards binary compatible. Applications linked against an older minor version will work with a newer minor version of the same major release without rebuilding. However, they may not be backwards compatible if the application uses extensions introduced in the newer version.
    • Major releases (different Major): e.g., 3.x to 4.x. These break compatibility on purpose to clean up the API or change fundamentals. You must rebuild your application if you switch major versions.

    Note on SDKs: You can only have one Software Development Kit (headers and link-time libraries) installed at a time for a specific major version. Installing a newer major version SDK will overwrite the headers of the previous major version. To develop against multiple major versions, you must manually manage include and libdir paths.

  3. Override default dragger geometries using SO_DRAGGER_DIR

    master

    Coin comes with statically compiled scene graph geometries used as defaults for various draggers. You can override these defaults by setting the SO_DRAGGER_DIR environment variable to a directory containing replacement .iv files.

    To ensure the draggers correctly recognize and extract the parts from your custom geometries, you must follow these two requirements:

    1. Filename Matching: Use the exact same filenames for your .iv files as the original default geometries.
    2. Node Name Matching: Use the exact same node names within the .iv files as specified in the original geometry specifications.

    For more detailed implementation guidance, refer to "Customizing a Dragger" in Chapter 15 of "The Inventor Mentor" (ISBN 0-201-62495-8).

    # Example: Pointing Coin to a directory with custom dragger geometries
    export SO_DRAGGER_DIR=/path/to/your/custom/geometries
  4. Write test cases for Coin components

    master

    Coin uses an in-tree, minimal test runner defined in testsuite/CoinTest.h which provides a subset of Boost.Test-style macros like BOOST_AUTO_TEST_CASE and BOOST_CHECK_MESSAGE.

    To implement tests, wrap your test code inside an #ifdef COIN_TEST_SUITE block within the component's implementation (.cpp) file.

    Requirements:

    1. Include Order: The first #include in the file must be the header declaring the component being tested. Alternatively, you can add specific #include directives inside the COIN_TEST_SUITE block.
    2. End Directive: You must include the comment // COIN_TEST_SUITE after the #endif directive so the extractor can correctly identify the end of the block.
    3. Scope: Only public API parts can be tested, as the test suite is built and linked separately from the main Coin library.
    #ifdef COIN_TEST_SUITE
    #include "MyComponent.h"
    
    BOOST_AUTO_TEST_CASE(test_name)
      {
        // test-code ...
      }
    
    #endif // COIN_TEST_SUITE
  5. Build and run the dynamic load extensions example

    master

    This example demonstrates how to build shared objects and load them dynamically. Note that this specific setup is configured for Coin and may require Makefile modifications to work with other Open Inventor implementations.

    UNIX Instructions

    1. Build the shared objects using GNU make:

      make
    2. Update the dynamic load path to ensure the system can find the newly built shared objects:

      export LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH"
    3. Run the examinerviewer to load the scene file:

      ../SoGuiExamples/components/examinerviewer scene.iv
    4. Interact: Switch the viewer to interaction mode and use keyboard keys to observe the reaction in the 3D model.

    CYGWIN Instructions

    1. Build the shared objects using GNU make:

      make
    2. Update the PATH (though often unnecessary for the current directory in Cygwin):

      export PATH=".:$PATH"
    3. Run the examinerviewer:

      ../SoGuiExamples/components/examinerviewer scene.iv
    # UNIX Build and Run sequence
    make
    export LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH"
    ../SoGuiExamples/components/examinerviewer scene.iv
  6. Embed superglu extension in Coin

    master

    Coin supports an optional extension called superglu, which is a custom version of GLU 1.3. If you encounter issues with standard GLU, you can embed superglu into your Coin build.

    To do this, clone the superglu repository into the src/extensions/ directory of your Coin source tree, then rerun the configure script and rebuild Coin.

    hg clone http://hg.sim.no/superglu/default superglu
    # Then rerun configure and rebuild Coin
  7. Register new test files in the test suite

    master

    When you add a new .cpp file containing test cases, the CMake-based extractor (testsuite/CMakeLists.txt) will discover it, but the internal list of files containing test code is not updated automatically.

    You must manually trigger an update of the file list by running the following command from the top-level directory:

    make makefile-update
  8. Migration: Boost dependency removal

    master

    As of recent updates (around version 4.0.8), Coin has removed its dependency on the Boost libraries.

    Key changes for developers:

    • Smart Pointers: The library no longer uses boost::intrusive_ptr or other Boost-specific pointer helpers. A new internal smart pointer header include/Inventor/misc/SoRefPtr.h has been introduced to replace them.
    • Testing: The project has replaced Boost.Test with a custom in-tree test runner located in the testsuite/ directory.
    • Build System: Autotools and CMake configurations have been cleaned of Boost references and associated scripts (e.g., findNecessaryBoostIncludes.sh).

    If you are integrating Coin into a project that previously relied on Coin's Boost dependency, you should update your code to use SoRefPtr.h for reference counting and ensure your build environment no longer requires Boost for Coin-related tasks.

  9. Verify camera setting compliance in .iv files

    master
    To verify that camera settings in .iv files are compliant and behave correctly across different aspect ratios, resize the viewer window in both directions. Specifically, test the viewer by making the window larger in the vertical dimension than the horizontal dimension, and then vice versa. This ensures the camera settings handle varying window proportions as expected.
  10. Run and debug the Coin test suite

    master

    After building Coin, you can execute the tests or debug crashes using the following commands from the top-level directory:

    • Run all tests: make testsuite-run
    • Run tests from within the testsuite directory: make
    • Identify crashing test cases: If the suite crashes, run make verbose to see detailed output and pinpoint the failing case.
    • Debug with GDB: To run the test suite inside a debugger (useful for crashes), use make debug.

    Note: make debug is only supported on platforms using gcc and gdb (e.g., Linux, macOS, Unix) and is not currently supported on Windows.

    # Run tests
    make testsuite-run
    
    # Debugging
    make verbose
    make debug