Scene
[Scene](/reference/nodes/scene)
is the top-level container for all nodes in a VGLX application. It acts as the root of the scene graph and is responsible for propagating update and input events throughout the hierarchy. Each application has one active scene at a time, which is managed by the [Application](/reference/core/application)
.
A custom scene can be created by inheriting from this class and overriding behavior or adding initial nodes. The scene must be provided to the application during startup:
class MyApp : public vglx::Application {
public:
auto Configure() -> void override {
params.title = "My App";
}
auto CreateScene() -> std::shared_ptr<vglx::Scene> override {
auto scene = vglx::Scene::Create();
// Add nodes to the scene
return scene;
}
auto Update(float delta) -> bool override {
// Called every frame
return true;
}
};
INFO
Derives from Node and inherits all public properties and methods.
Construction
Constructors
Factories preferred
Scene::Create() auto
static auto vglx::Scene::Create()
Creates a shared pointer to a Scene object.
Properties
Functions
Advance() void
void vglx::Scene::Advance(float delta)
Parameter | Description |
---|---|
delta | Elapsed time in seconds since the last frame. |
Advances the scene by one frame. Propagates the per-frame update through the scene graph, calling Node::Update(float delta)
on all attached nodes in depth-first order. This is invoked automatically by the runtime each frame.
GetNodeType() Node::Type virtual
Node::Type vglx::Scene::GetNodeType() const override
Returns node type.
SetContext() void
void vglx::Scene::SetContext(SharedContextPointer context)
Parameter | Description |
---|---|
context | Pointer to the active SharedContext instance (const). |
Attaches a shared context to the scene. Deprecated
The context provides runtime parameters (e.g., window size, active camera) and resource loaders. This is normally called by the runtime during initialization. All nodes added to the scene will receive the context via Node::OnAttached
.