refactor: rename WindowManager to Application; move world ownership up

WindowManager.{h,cpp} -> Application.{h,cpp}

The Application class now owns the long-lived world (Scene, SystemGraph,
GameInterface) and is the single setup point. This removes the per-view
duplication where each GameView/PlayView loaded the binary and ran the
simulation independently, which double-simulated with two windows open.

Changes:
- WindowManager -> Application (class, files, includes, CMake)
- Application owns OScene scene_ / OSystemGraph graph_ (OwningPtr)
  and GameInterface* gameInterface (raw, deleted in dtor)
- loadGame(graphics, path, name): single world-setup point
  (dlopen -> setupScene -> append 5 editor systems)
- attachWorld(OScene, OSystemGraph): worldless hosts (benchmark)
  hand ownership in via move
- Frame-loop fix: systemGraph->run() now runs ONCE per frame, before
  the window loop (was per-window -> double-simulated with 2 windows)
- Editor/main.cpp + Benchmark/main.cpp rewired to the new API
- Window.h/.cpp: PWindowManager back-pointer -> PApplication
- 8 include paths updated to Window/Application.h

Compile-verified: Application.cpp, Editor/main.cpp, Benchmark/main.cpp
all pass g++ -std=c++23 -fsyntax-only against the full third-party
include set.
This commit is contained in:
coding-agent authored and Dynamitos committed 2026-11-09 20:07:40 +01:00
1 parent 803531c608
commit 1e34f0e67b
13 files changed
+194 -86

No files matched your search

+12 -18
View File
@@ -16,7 +16,7 @@
#include "System/FluidUpdater.h"
#include "System/LightGather.h"
#include "System/MeshUpdater.h"
#include "Window/WindowManager.h"
#include "Window/Application.h"
#include "Window/InspectorView.h"
#include "Scene/Scene.h" // OScene/Scene - the InspectorView's entity pane needs a live scene
#include "Component/Transform.h"
@@ -141,18 +141,12 @@ int main(int argc, char** argv) {
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
vd->init(graphics);
GameInterface gameInterface(binaryPath);
OScene scene = new Scene(graphics);
gameInterface.reload();
OSystemGraph systemGraph = new SystemGraph();
gameInterface.getGame()->setupScene(scene, systemGraph);
systemGraph->addSystem(new System::KeyboardInput(scene));
systemGraph->addSystem(new System::FluidUpdater(scene));
systemGraph->addSystem(new System::LightGather(scene));
systemGraph->addSystem(new System::MeshUpdater(scene));
systemGraph->addSystem(new System::CameraUpdater(scene));
OWindowManager windowManager = new WindowManager(systemGraph);
// The world (Scene + SystemGraph) and the game binary are owned by the
// Application from here on. `loadGame` dlopen's the .so, lets the game
// populate the scene+graph, and appends the editor's own systems. Views
// below only render the non-owning application->scene() handle.
OApplication application = new Application();
application->loadGame(graphics, sourcePath, gameName);
AssetRegistry::init(sourcePath / "Assets", graphics);
AssetImporter::init(graphics);
AssetImporter::importFont(FontImportArgs{
@@ -187,7 +181,7 @@ int main(int argc, char** argv) {
.title = "SeeleEngine",
.preferredFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB,
};
auto window = windowManager->addWindow(graphics, mainWindowInfo);
auto window = application->addWindow(graphics, mainWindowInfo);
ViewportCreateInfo sceneViewInfo = {
.dimensions =
{
@@ -195,7 +189,7 @@ int main(int argc, char** argv) {
.offset = {0, 0},
},
};
OGameView sceneView = new Editor::PlayView(graphics, window, scene, sceneViewInfo);
OGameView sceneView = new Editor::PlayView(graphics, window, application->scene(), sceneViewInfo);
sceneView->setFocused();
OInspectorView inspectorView = new Editor::InspectorView(graphics, window,
ViewportCreateInfo{
@@ -205,12 +199,12 @@ int main(int argc, char** argv) {
.offset = {0, 0},
},
},
/* scene = */ scene);
/* scene = */ application->scene());
inspectorView->setFocused();
window->show();
while (windowManager->isActive() && getGlobals().running) {
windowManager->render();
while (application->isActive() && getGlobals().running) {
application->render();
}
graphics->waitDeviceIdle();
Material::destroy();