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.
72 lines
2.2 KiB
C++
72 lines
2.2 KiB
C++
#include "Asset/AssetRegistry.h"
|
|
#include "Graphics/Initializer.h"
|
|
#include "Graphics/StaticMeshVertexData.h"
|
|
#include "Graphics/Vulkan/Graphics.h"
|
|
#include "PlayView.h"
|
|
#include "Scene/Scene.h"
|
|
#include "System/SystemGraph.h"
|
|
#include "Window/Application.h"
|
|
#include <fmt/core.h>
|
|
#include <random>
|
|
|
|
using namespace Seele;
|
|
|
|
// make it global so it gets deleted last and automatically
|
|
static Gfx::OGraphics graphics;
|
|
|
|
int main(int argc, char** argv) {
|
|
if (argc > 2)
|
|
{
|
|
return -1;
|
|
}
|
|
bool useDepthCulling = true;
|
|
if (argc == 2 && strcmp(argv[1], "NOCULL") == 0)
|
|
{
|
|
useDepthCulling = false;
|
|
}
|
|
|
|
std::filesystem::path binaryPath = "MeshShadingDemo.dll";
|
|
|
|
graphics = new Vulkan::Graphics();
|
|
GraphicsInitializer initializer;
|
|
graphics->init(initializer);
|
|
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
|
|
vd->init(graphics);
|
|
getGlobals().useRayTracing = true;
|
|
|
|
// The benchmark is a worldless host: it builds a plain Scene + SystemGraph
|
|
// (no game binary) and hands ownership to the Application, which then steps
|
|
// it once per frame and lets the views render it. The view renders the
|
|
// non-owning application->scene() handle.
|
|
OApplication application = new Application();
|
|
OScene scene = new Scene(graphics);
|
|
OSystemGraph systemGraph = new SystemGraph();
|
|
application->attachWorld(std::move(scene), std::move(systemGraph));
|
|
AssetRegistry::init("Assets", graphics);
|
|
vd->commitMeshes();
|
|
WindowCreateInfo mainWindowInfo = {
|
|
.width = 1920,
|
|
.height = 1080,
|
|
.title = "Benchmark",
|
|
.preferredFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB,
|
|
};
|
|
auto window = application->addWindow(graphics, mainWindowInfo);
|
|
ViewportCreateInfo sceneViewInfo = {
|
|
.dimensions =
|
|
{
|
|
.size = {1920, 1080},
|
|
.offset = {0, 0},
|
|
},
|
|
};
|
|
OGameView sceneView = new PlayView(graphics, window, application->scene(), sceneViewInfo, useDepthCulling);
|
|
sceneView->setFocused();
|
|
|
|
while (application->isActive()) {
|
|
application->render();
|
|
}
|
|
graphics->waitDeviceIdle();
|
|
vd->destroy();
|
|
|
|
return 0;
|
|
}
|