Skip to content

Scene

Root node and entry point for a scene graph.

[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:

cpp
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


Scene()

cpp
vglx::Scene::Scene()

Constructs an Scene instance.

Factories preferred


Scene::Create() auto

cpp
static auto vglx::Scene::Create()

Creates a shared pointer to a Scene object.

Properties

fog std::unique_ptr<Fog>

cpp
std::unique_ptr<Fog> fog

Fog settings applied to the entire scene.

Functions

Advance() void

cpp
void vglx::Scene::Advance(float delta)
ParameterDescription
deltaElapsed 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

cpp
Node::Type vglx::Scene::GetNodeType() const override

Returns node type.

SetContext() void

cpp
void vglx::Scene::SetContext(SharedContextPointer context)
ParameterDescription
contextPointer 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.

Released under the MIT License.