Scene
Scene is the top-level container for all nodes that participate in rendering and updates. It owns the scene graph hierarchy, optional global fog settings, and a shared runtime context. Create a scene by overriding the application runtime Application::CreateScene. The runtime will attach it to the active context and advance it once per frame.
class MyApp : public vglx::Application {
public:
auto Configure() -> Application::Parameters override {
return {
.title = "Hello VGLX",
.clear_color = {0x000000},
.width = 1280,
.height = 720,
.antialiasing = 4,
};
}
auto CreateScene() -> std::unique_ptr<vglx::Scene> override {
auto scene = vglx::Scene::Create();
scene->fog = vglx::Fog::CreateExponential(0x444444, 0.3f);
// Add nodes to the scene...
return scene;
}
auto Update(float delta) -> bool override {
return true;
}
};INFO
Derives from Node and inherits all public properties and methods.
Construction
Constructors
Scene()
Constructs a scene object.
Scene::Scene();Factories preferred
Creates an instance of Scene.
static std::unique_ptr<Scene> Scene::Create();Properties
Optional for defining a flat texture background.
std::shared_ptr<Texture> background {nullptr};Optional global fog settings applied during rendering.
std::optional<Fog> fog {};Functions
Advance() void
Advances the scene by one frame.
Propagates per-frame updates through the scene graph, calling OnUpdate on the scene and all attached nodes in depth-first order. This is invoked automatically by the runtime once per frame.
void Scene::Advance(float delta);| Parameter | Description |
|---|---|
| delta | Elapsed time in seconds since the last frame. |
GetContext() SharedContextPointer
Returns the active shared context.
Returns the context previously set via SetContext, or nullptr if the scene has not been attached to a context yet.
SharedContextPointer Scene::GetContext() const;GetNodeType() Node::Type virtual
Identifies this node as Node::Type::Scene.
Type vglx::Scene::GetNodeType() const override;SetContext() void
Attaches a shared context to the scene.
Stores the active shared context and propagates it to all nodes in the scene graph via Node::OnAttached. The context provides access to runtime state such as the active camera, window parameters, and renderer resources. This is normally called by the application runtime during initialization.
void Scene::SetContext(SharedContextPointer context);| Parameter | Description |
|---|---|
| context | Pointer to the active SharedContext instance. |