Scene
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.
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
Scene()
Constructs an Scene instance.
Scene::Scene();Factories preferred
Scene::Create() auto
Creates a shared pointer to a Scene object.
static auto Scene::Create();Properties
Fog settings applied to the entire scene. Set this to a LinearFog or ExponentialFog instance to enable distance-based atmospheric fading. This is typically done during scene setup.
scene->fog = vglx::LinearFog::Create(0x444444, 2.0f, 6.0f);std::unique_ptr<Fog> fog {};Functions
Advance() void
Advances the scene by one frame.
Propagates the per-frame update through the scene graph, calling NodeUpdate(float delta) on all attached nodes in depth-first order. This is invoked automatically by the runtime each frame.
void Scene::Advance(float delta);| Parameter | Description |
|---|---|
| delta | Elapsed time in seconds since the last frame. |
GetNodeType() Node::Type virtual
Returns node type.
Type vglx::Scene::GetNodeType() const override;SetContext() void
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 NodeOnAttached.
void Scene::SetContext(SharedContextPointer context);| Parameter | Description |
|---|---|
| context | Pointer to the active SharedContext instance (const). |