Skip to main content

Overview

GraphicsObjectInterface is the base interface for all renderable graphics objects in the Open Mobile Maps SDK. It defines the contract for graphics primitives that can be rendered on the map, including setup, lifecycle management, and rendering operations. Graphics objects are created through the GraphicsObjectFactoryInterface and are used by layers to display visual content. Header Location: shared/public/GraphicsObjectInterface.h:13

Lifecycle Methods

setup
void
Initializes the graphics object with a rendering context.
Must be called on the graphics/rendering thread.
clear
void
Clears the graphics object and invalidates its ready state.After calling this method, isReady() will return false until setup() is called again.
isReady
bool
Checks if the graphics object is ready to be rendered.
return
bool
True if the object is ready to be drawn, false otherwise

Configuration Methods

setIsInverseMasked
void
Sets whether masking should be applied inversely.By default, masked objects are only rendered where the mask is set. Setting this flag applies the mask inversely, rendering only where the mask is not set.
setDebugLabel
void
Sets a debug label for the graphics object.This label can be used for debugging and profiling purposes.

Rendering Methods

render
void
Renders the graphics object.
Must be called on the graphics/rendering thread.

Graphics Object Factory

Graphics objects are created using the GraphicsObjectFactoryInterface, which provides factory methods for different types of primitives:

2D Primitives

createQuad
std::shared_ptr<Quad2dInterface>
Creates a 2D quad (rectangle) graphics object.
createQuadTessellated
std::shared_ptr<Quad2dInterface>
Creates a tessellated 2D quad for smooth curved surfaces.
createPolygon
std::shared_ptr<Polygon2dInterface>
Creates a 2D polygon graphics object.
createPolygonTessellated
std::shared_ptr<Polygon2dInterface>
Creates a tessellated 2D polygon.

Instanced Rendering

createQuadInstanced
std::shared_ptr<Quad2dInstancedInterface>
Creates an instanced quad for efficient batch rendering.
createQuadStretchedInstanced
std::shared_ptr<Quad2dStretchedInstancedInterface>
Creates an instanced stretched quad.

Groups and Collections

createLineGroup
std::shared_ptr<LineGroup2dInterface>
Creates a line group for rendering multiple lines efficiently.
createPolygonGroup
std::shared_ptr<PolygonGroup2dInterface>
Creates a polygon group for rendering multiple polygons efficiently.
createPolygonPatternGroup
std::shared_ptr<PolygonPatternGroup2dInterface>
Creates a polygon pattern group for textured polygons.

Text Rendering

createText
std::shared_ptr<TextInterface>
Creates a text graphics object.
createTextInstanced
std::shared_ptr<TextInstancedInterface>
Creates an instanced text object for efficient text rendering.

3D Primitives

createIcosahedronObject
std::shared_ptr<IcosahedronInterface>
Creates an icosahedron (20-sided polyhedron) for 3D rendering.

Masking Objects

createQuadMask
std::shared_ptr<Quad2dInterface>
Creates a quad for use as a mask.
createPolygonMask
std::shared_ptr<Polygon2dInterface>
Creates a polygon for use as a mask.
createPolygonMaskTessellated
std::shared_ptr<Polygon2dInterface>
Creates a tessellated polygon for use as a mask.

Usage Example

// Get the graphics object factory from the map
auto factory = map->getGraphicsObjectFactory();
auto shaderFactory = map->getShaderFactory();

// Create a shader for the quad
auto shader = shaderFactory->createAlphaShader();

// Create a quad graphics object
auto quad = factory->createQuad(shader);

// Set debug label
quad->setDebugLabel("MyQuad");

// Setup the graphics object (on rendering thread)
auto context = map->getRenderingContext();
quad->setup(context);

// Check if ready
if (quad->isReady()) {
    // Render the quad (on rendering thread)
    RenderPassConfig renderPass;
    quad->render(
        context,
        renderPass,
        vpMatrixPtr,
        mMatrixPtr,
        Vec3D{0, 0, 0},
        false,  // not masked
        1.0,    // pixel to meter factor
        false   // not screen space
    );
}

// Clean up
quad->clear();

Render Object Wrapper

Graphics objects are typically wrapped in RenderObjectInterface which provides additional rendering control:
class RenderObjectInterface {
    virtual std::shared_ptr<GraphicsObjectInterface> getGraphicsObject() = 0;
    virtual bool hasCustomModelMatrix() = 0;
    virtual bool isScreenSpaceCoords() = 0;
    virtual std::vector<float> getCustomModelMatrix() = 0;
    virtual void setHidden(bool hidden) = 0;
    virtual bool isHidden() = 0;
};

Graphics Object Types

The SDK provides several specialized graphics object types:
  • Quad2dInterface - 2D rectangles
  • Polygon2dInterface - 2D polygons
  • LineGroup2dInterface - Collections of lines
  • PolygonGroup2dInterface - Collections of polygons
  • TextInterface - Text rendering
  • IcosahedronInterface - 3D spherical objects
  • Instanced variants - For efficient batch rendering

See Also

Build docs developers (and LLMs) love