utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
utility::Engine Class Referenceabstract

Engine interface combining rendering and event handling. More...

#include <headers/utility/engine.hpp>

Inheritance diagram for utility::Engine:
Collaboration diagram for utility::Engine:

Public Types

using ViewportSize = utility::math::Vector2F
 2D vector representing viewport width and height in pixels.
 
using Handler = std::function< void(std::shared_ptr< utility::event::Event > &)>
 Type alias for an event handler callback function.
 

Public Member Functions

bool shouldCaptureViewportInput (void) const
 Check if viewport input capture is enabled.
 
void setShouldCaptureViewportInput (bool capture)
 Set the viewport input capture state.
 
 Engine (void)
 Default constructor.
 
virtual ~Engine (void)=default
 Default destructor.
 
virtual void clear (void)=0
 Clear the current rendering target with the drawing color.
 
virtual void present (void)=0
 Present the composed back buffer to the screen.
 
virtual size_t addMesh (const utility::graphic::Mesh &mesh, const std::string &materialName)=0
 Add a mesh to the engine.
 
virtual bool removeObject (size_t objectID)=0
 Remove a previously added render object.
 
virtual utility::graphic::SizeF measureText (const utility::graphic::Text &text) const =0
 Measures the pixel dimensions of a given text string when rendered with a specific font.
 
virtual size_t addText (utility::graphic::Text text)=0
 Add a text element to the engine at a specified pose.
 
virtual size_t addModel (std::shared_ptr< utility::graphic::Model > model)=0
 Add a model to the engine for rendering.
 
virtual utility::graphic::ViewF getView (void) const =0
 Get the full view model.
 
virtual void addScene (size_t sceneIndex)=0
 Add a scene to the engine.
 
void setEventCallback (const Handler &callback)
 Set the event callback function.
 
virtual void pollEvents (void)=0
 Poll for events and dispatch them.
 
virtual void update (void)=0
 Update the engine state.
 

Protected Member Functions

HandlergetEventCallback (void)
 Get the current event callback function.
 
- Protected Member Functions inherited from utility::logging::Loggable< Engine, utility::logging::DefaultLogger >
 Loggable (void)
 Construct a Loggable with the specified LoggerType.
 
 Loggable (Loggable &&other) noexcept
 Move constructor for Loggable.
 
Loggableoperator= (Loggable &&other) noexcept
 Move assignment operator for Loggable.
 
LoggerType & getLogger (void)
 Get the internal logger.
 
LoggerType & getLogger (void) const
 Get the internal logger.
 
virtual ~Loggable (void)=default
 Virtual destructor for proper cleanup.
 

Detailed Description

Engine interface combining rendering and event handling.

This class provides an abstract interface for the core engine loop. Implementations should provide platform-specific rendering and event polling capabilities.

class MyEngine : public Engine { ... };
Engine interface combining rendering and event handling.
Definition engine.hpp:60

Definition at line 57 of file engine.hpp.

Member Typedef Documentation

◆ Handler

using utility::Engine::Handler = std::function<void(std::shared_ptr<utility::event::Event> &)>

Type alias for an event handler callback function.

Takes a shared pointer to an Event and performs an action.

Definition at line 72 of file engine.hpp.

◆ ViewportSize

2D vector representing viewport width and height in pixels.

Definition at line 65 of file engine.hpp.

Member Function Documentation

◆ addMesh()

virtual size_t utility::Engine::addMesh ( const utility::graphic::Mesh mesh,
const std::string &  materialName 
)
pure virtual

Add a mesh to the engine.

Parameters
meshThe mesh to add to the engine.
materialNameThe name of the material to use for rendering the mesh.
Returns
A unique identifier for the added mesh.

◆ addModel()

virtual size_t utility::Engine::addModel ( std::shared_ptr< utility::graphic::Model model)
pure virtual

Add a model to the engine for rendering.

Parameters
modelA shared pointer to the model to add.
Returns
A unique identifier for the added model.

◆ addScene()

virtual void utility::Engine::addScene ( size_t  sceneIndex)
pure virtual

Add a scene to the engine.

Parameters
sceneIndexThe index of the scene to add.

◆ addText()

virtual size_t utility::Engine::addText ( utility::graphic::Text  text)
pure virtual

Add a text element to the engine at a specified pose.

Parameters
textThe text to draw.
Returns
A unique identifier for the added text.

◆ getEventCallback()

Handler & utility::Engine::getEventCallback ( void  )
protected

Get the current event callback function.

Returns
Reference to the event callback function.

◆ getView()

virtual utility::graphic::ViewF utility::Engine::getView ( void  ) const
pure virtual

Get the full view model.

Returns
The view instance.

◆ measureText()

virtual utility::graphic::SizeF utility::Engine::measureText ( const utility::graphic::Text text) const
pure virtual

Measures the pixel dimensions of a given text string when rendered with a specific font.

Parameters
textThe text to measure.
Returns
A 2D vector containing the width and height of the rendered text in pixels in the form of utility::math::Vector2F.

◆ pollEvents()

virtual void utility::Engine::pollEvents ( void  )
pure virtual

Poll for events and dispatch them.

This method should check for pending events from the underlying platform, convert them to Event objects, and call the registered callback for each event.

◆ removeObject()

virtual bool utility::Engine::removeObject ( size_t  objectID)
pure virtual

Remove a previously added render object.

Parameters
objectIDThe identifier returned by addMesh/addText.
Returns
True when the object was removed.

◆ setEventCallback()

void utility::Engine::setEventCallback ( const Handler callback)

Set the event callback function.

The callback will be invoked for each event when pollEvents() is called.

Parameters
callbackFunction to call when an event is received.

◆ setShouldCaptureViewportInput()

void utility::Engine::setShouldCaptureViewportInput ( bool  capture)

Set the viewport input capture state.

Parameters
captureTrue to enable viewport input capture, false to disable. When disabled, input is routed to UI instead of camera controls.

◆ shouldCaptureViewportInput()

bool utility::Engine::shouldCaptureViewportInput ( void  ) const

Check if viewport input capture is enabled.

Returns
True when viewport input is captured for camera movement.

◆ update()

virtual void utility::Engine::update ( void  )
pure virtual

Update the engine state.

This method should handle logic updates, input processing, and other non-rendering related tasks. It is typically called once per frame, allowing the engine to respond to user input and update the state of objects in the scene.


The documentation for this class was generated from the following file: