apps/webgpu_app/main.cpp creates the webgpu_app::App, which owns the SDL window, the WebGPU device, and the render loop (App.cpp). Each frame:
ImGuiManager::render()records the ImGui draw commands for the UI on top of the scene.- The 3D scene (terrain, overlays) is rendered via
webgpu_engineonly on demand (e.g. on camera change). Bothwebgpu_engineand the compute graph depend onwebgpu_basefor shader preprocessing, GPU resource management, and RAII wrappers.
graph LR
App("App")
WebGPUCtx("webgpu::Context")
Window("webgpu_engine::Window")
CameraCtrl("camera::Controller")
ImGuiMgr("ImGuiManager")
OverlaysPanel("OverlaysPanel")
NodeGraphPanel("NodeGraphPanel *")
OverlayImGuiR[["OverlayImGuiRenderer[ ]"]]
NodeGraph(["NodeGraph *"])
NodeRenderers[["NodeRenderer[ ] *"]]
panels[["Panels[ ]"]]
RenderCtx("RenderingContext")
EngineCtx("webgpu_engine::Context")
Schedulers("Schedulers / CloudsManager / SearchService")
App --> WebGPUCtx
App --> Window
App --> CameraCtrl
App --> ImGuiMgr
App --> RenderCtx
ImGuiMgr --> panels
panels --> OverlaysPanel
panels --> NodeGraphPanel
OverlaysPanel --> OverlayImGuiR
OverlaysPanel -.-> EngineCtx
NodeGraphPanel --> NodeGraph
NodeGraphPanel --> NodeRenderers
NodeGraphPanel -.-> EngineCtx
RenderCtx --> EngineCtx
RenderCtx --> Schedulers
* ... only compiled when ALP_WEBGPU_APP_ENABLE_COMPUTE is enabled.
This class is tying the UI together:
- Initializes the Dear ImGui / ImNodes contexts and fonts.
- Owns the list of
ImGuiPanels and draws them every frame. - Forwards SDL events to ImGui
- Offers some static helper functions
All panels implement the ImGuiPanel interface (apps/webgpu_app/ui/ImGuiPanel.h)
In general we follow a feature-based directory layout - each feature folder owns its panel (e.g. overlay/OverlaysPanel, compute/NodeGraphPanel). General-purpose panels live in apps/webgpu_app/ui/. New panels must be manually instantiated and registered in ImGuiManager (apps/webgpu_app/ImGuiManager.cpp).
OverlaysPanel is the ImGui panel used to configure which overlays are active and their settings - the actual rendering is done by the corresponding webgpu_engine::OverlayRenderer. Each overlay type can have a matching OverlayImGuiRenderer subclass (apps/webgpu_app/overlay/) that draws its settings controls.
If no specific subclass is registered, the base OverlayImGuiRenderer serves as a fallback.
Note
After adding a new Overlay to the engine you have to:
OverlaysPanel.cpp: extend theAddTypeenum andADD_ITEMS[]array and add a branch inadd_overlay_of_type()to instantiate the new type.
and optionally
- UI renderer: create a matching
OverlayImGuiRenderersubclass inapps/webgpu_app/overlay/ OverlayImGuiRendererFactory.cpp: add adynamic_castbranch inOverlayImGuiRendererFactory::create()
The NodeGraphPanel (apps/webgpu_app/compute/) manages the active NodeGraph and owns one NodeRenderer per node instance, providing the visual/interactive representation in the node-graph editor. Each node type can have a matching NodeRenderer subclass (apps/webgpu_app/compute/nodes/)
If no specific subclass is registered, the base NodeRenderer is used as a fallback (renders the node with sockets but no settings panel).
Note
When adding a new compute node type, three files must be touched:
- Compute node: create a
Nodesubclass inwebgpu/compute/nodes/(the engine-side compute logic). - Node registry: call
register_node()inNodeRegistry::NodeRegistry()so the node can be instantiated by name (required for graph serialization / the add-node dialog). - UI renderer: optionally create a
NodeRenderersubclass inapps/webgpu_app/compute/nodes/and add adynamic_castbranch inNodeRendererFactory::create()
OverlayRenderNode (apps/webgpu_app/compute/OverlayRenderNode.h) is a special node that bridges the compute graph and the rendering system. Unlike regular compute nodes it lives in the app layer because it holds a reference to webgpu_engine::Context. When executed, it forwards the graph's output texture to a TextureOverlay managed by the engine's OverlayRenderer, making compute results visible in the 3D viewport.