SharedContext
Provides access to shared parameters and services.
The SharedContext class encapsulates common runtime parameters and services that are shared across the scene graph. This context is created internally within the runtime and made available to nodes once they are added to the active scene.
Access to the shared context is provided through the Node::OnAttached callback, which is invoked when the node becomes part of an active scene hierarchy. Override this method in your node class to perform initialization that depends on the context, such as loading resources, accessing the active camera, etc.
cpp
class MyNode : public vglx::Node {
public:
void OnAttached(SharedContextPointer context) override {
context->texture_loader->LoadAsync(
"assets/checker.tex",
[this](auto result) {
if (result) {
texture_ = result.value();
} else {
std::println(stderr, "{}", result.error());
}
}
);
}
};
Properties
aspect_ratio float
cpp
float aspect_ratio
Aspect ratio of the render surface.
framebuffer_height int
cpp
int framebuffer_height
Frambuffer height in physical pixels.
framebuffer_width int
cpp
int framebuffer_width
Framebuffer width in physical pixels.
mesh_loader std::shared_ptr<MeshLoader>
cpp
std::shared_ptr<MeshLoader> mesh_loader { MeshLoader::Create() }
Mesh loader.
texture_loader std::shared_ptr<TextureLoader>
cpp
std::shared_ptr<TextureLoader> texture_loader { TextureLoader::Create() }
Texture loader.
window_height int
cpp
int window_height
Window height in logical units.
window_width int
cpp
int window_width
Window width in logical units.