forked from Dynamitos/Seele
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.
60 lines
2.3 KiB
C++
60 lines
2.3 KiB
C++
#pragma once
|
|
#include "Containers/Array.h"
|
|
#include "System/SystemGraph.h"
|
|
#include "Window.h"
|
|
#include <filesystem>
|
|
|
|
namespace Seele {
|
|
DECLARE_NAME_REF(Gfx, Graphics)
|
|
DECLARE_REF(Scene)
|
|
class Game;
|
|
class GameInterface;
|
|
|
|
// The long-lived top-level application object.
|
|
//
|
|
// Owns the *world*: the single Scene, the single SystemGraph (the running
|
|
// simulation) and the loaded game binary (GameInterface). There is exactly one
|
|
// of these per process, and it steps the simulation exactly once per frame --
|
|
// regardless of how many windows/views observe the scene. Views hold a
|
|
// non-owning PScene and only render; they never own the world.
|
|
//
|
|
// This is the old "WindowManager", renamed so its true responsibilities
|
|
// (windowing + world ownership + the frame loop) are named honestly.
|
|
class Application {
|
|
public:
|
|
Application();
|
|
~Application();
|
|
|
|
// Loads the game binary (dlopen) and lets it populate the Scene +
|
|
// SystemGraph it owns, then appends the editor's own systems. Called once,
|
|
// by the embedding host (the editor / benchmark main). `graphics` is needed
|
|
// to construct the Scene; `sourcePath`/`gameName` resolve the .so.
|
|
void loadGame(Gfx::PGraphics graphics, const std::filesystem::path& sourcePath, const std::string& gameName);
|
|
|
|
// Window management
|
|
OWindow addWindow(Gfx::PGraphics graphics, const WindowCreateInfo& createInfo);
|
|
void notifyWindowClosed(PWindow window);
|
|
bool isActive() const { return getGlobals().running && windows.size(); }
|
|
|
|
// Per-frame driver: steps the world ONCE, then renders every window.
|
|
void render();
|
|
|
|
// Non-owning handles so views can render the shared world.
|
|
PScene scene() const { return scene_; }
|
|
PSystemGraph systemGraph() const { return graph_; }
|
|
|
|
// Worldless hosts (e.g. the GPU-timing benchmark, which has no game binary)
|
|
// build their own world and hand ownership in; the owning members take it via
|
|
// move so the frame loop can step `graph_` and views can render `scene_`.
|
|
void attachWorld(OScene scene, OSystemGraph graph);
|
|
|
|
private:
|
|
Array<PWindow> windows;
|
|
Gfx::PGraphics graphics;
|
|
OScene scene_;
|
|
OSystemGraph graph_;
|
|
GameInterface* gameInterface = nullptr; // owned by Application (dlclose'd in dtor)
|
|
};
|
|
DEFINE_REF(Application)
|
|
} // namespace Seele
|