VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
visutwin::canvas::Engine Class Reference

Central application orchestrator managing scenes, rendering, input, and resource loading. More...

#include <framework/engine.h>

Inheritance diagram for visutwin::canvas::Engine:
[legend]

Public Member Functions

BatchManagerbatcher ()
void destroy ()
 Engine (SDL_Window *window)
float fixedDeltaTime () const
float fixedTimeAlpha () const
void fixedUpdate (float fixedDt)
const std::shared_ptr< GraphicsDevice > & graphicsDevice () const
void init (const AppOptions &appOptions)
void inputUpdate (float dt)
const std::shared_ptr< ResourceLoader > & loader () const
int maxFixedSubSteps () const
void render ()
std::pair< int, int > resizeCanvas (int width=0, int height=0)
std::shared_ptr< Entityroot ()
const std::shared_ptr< Scene > & scene () const
std::shared_ptr< ScriptRegistryscripts () const
SDL_Window * sdlWindow () const
void setCanvasFillMode (FillMode mode, int width=0, int height=0)
void setCanvasResolution (ResolutionMode mode, int width=0, int height=0)
void setFixedDeltaTime (float dt)
void setMaxFixedSubSteps (int n)
void start ()
std::shared_ptr< ComponentSystemRegistrysystems () const
void update (float dt)
void updateCanvasSize ()
virtual ~Engine ()
Public Member Functions inherited from visutwin::canvas::EventHandler
template<typename... Args>
EventHandlerfire (const std::string &name, Args &&... args)
bool hasEvent (const std::string &name) const
void initEventHandler ()
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleroff (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleroff (const std::string &name="", const HandleEventCallback &callback=HandleEventCallback(), void *scope=nullptr)
EventHandleroffByHandle (EventHandle *handle)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleon (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleon (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleonce (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleonce (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
virtual ~EventHandler ()=default

Protected Member Functions

virtual double processTimestamp (double timestamp)
Protected Member Functions inherited from visutwin::canvas::EventHandler
EventHandleaddCallback (const std::string &name, HandleEventCallback callback, void *scope=nullptr, bool once=false)

Friends

MakeTickCallback makeTick (const std::shared_ptr< Engine > &engine)

Detailed Description

Central application orchestrator managing scenes, rendering, input, and resource loading.

Engine is the entry point for a VisuTwin Canvas application. It owns the GraphicsDevice, Scene, ForwardRenderer, component systems, and the async ResourceLoader. A typical frame calls update() -> fixedUpdate() (zero or more substeps) -> render().

Definition at line 37 of file engine.h.

Constructor & Destructor Documentation

◆ Engine()

visutwin::canvas::Engine::Engine ( SDL_Window * window)
inline

Definition at line 40 of file engine.h.

◆ ~Engine()

visutwin::canvas::Engine::~Engine ( )
virtual

Definition at line 95 of file engine.cpp.

References destroy().

Member Function Documentation

◆ batcher()

BatchManager * visutwin::canvas::Engine::batcher ( )
inline

batcher accessor.

Definition at line 101 of file engine.h.

◆ destroy()

void visutwin::canvas::Engine::destroy ( )

Definition at line 100 of file engine.cpp.

References visutwin::canvas::EventHandler::fire().

Referenced by ~Engine().

◆ fixedDeltaTime()

float visutwin::canvas::Engine::fixedDeltaTime ( ) const
inline

Definition at line 82 of file engine.h.

◆ fixedTimeAlpha()

float visutwin::canvas::Engine::fixedTimeAlpha ( ) const
inline

Definition at line 90 of file engine.h.

◆ fixedUpdate()

void visutwin::canvas::Engine::fixedUpdate ( float fixedDt)

Definition at line 636 of file engine.cpp.

References visutwin::canvas::EventHandler::fire().

Referenced by update().

◆ graphicsDevice()

const std::shared_ptr< GraphicsDevice > & visutwin::canvas::Engine::graphicsDevice ( ) const
inline

Definition at line 53 of file engine.h.

◆ init()

◆ inputUpdate()

void visutwin::canvas::Engine::inputUpdate ( float dt)

Definition at line 532 of file engine.cpp.

Referenced by update().

◆ loader()

const std::shared_ptr< ResourceLoader > & visutwin::canvas::Engine::loader ( ) const
inline

Async resource loader — single background I/O thread with main-thread callbacks.

Definition at line 104 of file engine.h.

◆ maxFixedSubSteps()

int visutwin::canvas::Engine::maxFixedSubSteps ( ) const
inline

Definition at line 85 of file engine.h.

◆ processTimestamp()

virtual double visutwin::canvas::Engine::processTimestamp ( double timestamp)
inlineprotectedvirtual

Definition at line 107 of file engine.h.

◆ render()

void visutwin::canvas::Engine::render ( )

Definition at line 314 of file engine.cpp.

References visutwin::canvas::EventHandler::fire().

◆ resizeCanvas()

std::pair< int, int > visutwin::canvas::Engine::resizeCanvas ( int width = 0,
int height = 0 )

◆ root()

std::shared_ptr< Entity > visutwin::canvas::Engine::root ( )
inline

Definition at line 92 of file engine.h.

◆ scene()

const std::shared_ptr< Scene > & visutwin::canvas::Engine::scene ( ) const
inline

Definition at line 52 of file engine.h.

◆ scripts()

std::shared_ptr< ScriptRegistry > visutwin::canvas::Engine::scripts ( ) const
inline

Definition at line 94 of file engine.h.

◆ sdlWindow()

SDL_Window * visutwin::canvas::Engine::sdlWindow ( ) const
inline

Definition at line 98 of file engine.h.

◆ setCanvasFillMode()

void visutwin::canvas::Engine::setCanvasFillMode ( FillMode mode,
int width = 0,
int height = 0 )

Definition at line 400 of file engine.cpp.

References resizeCanvas().

◆ setCanvasResolution()

void visutwin::canvas::Engine::setCanvasResolution ( ResolutionMode mode,
int width = 0,
int height = 0 )

Definition at line 442 of file engine.cpp.

References visutwin::canvas::RESOLUTION_AUTO.

◆ setFixedDeltaTime()

void visutwin::canvas::Engine::setFixedDeltaTime ( float dt)
inline

Definition at line 83 of file engine.h.

◆ setMaxFixedSubSteps()

void visutwin::canvas::Engine::setMaxFixedSubSteps ( int n)
inline

Definition at line 86 of file engine.h.

◆ start()

void visutwin::canvas::Engine::start ( )

Definition at line 308 of file engine.cpp.

◆ systems()

std::shared_ptr< ComponentSystemRegistry > visutwin::canvas::Engine::systems ( ) const
inline

Definition at line 96 of file engine.h.

◆ update()

void visutwin::canvas::Engine::update ( float dt)

Definition at line 548 of file engine.cpp.

References visutwin::canvas::EventHandler::fire(), fixedUpdate(), and inputUpdate().

◆ updateCanvasSize()

void visutwin::canvas::Engine::updateCanvasSize ( )

Definition at line 657 of file engine.cpp.

References visutwin::canvas::RESOLUTION_AUTO.

Referenced by resizeCanvas().

◆ makeTick

MakeTickCallback makeTick ( const std::shared_ptr< Engine > & engine)
friend

Definition at line 24 of file engine.cpp.

Referenced by init().


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