Compare commits

...
2 Commits
Author SHA1 Message Date
coding-agent 167bbce163 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.
2026-11-09 17:23:42 +00:00
Dynamitos 1bb36333e6 Fix miscellaneus errors 2026-11-08 23:00:57 +01:00
26 changed files with 319 additions and 153 deletions

No files matched your search

+85 -32
View File
@@ -1,5 +1,27 @@
import lldb
def _member(valobj, name):
# GetChildMemberWithName does not search base classes reliably across
# LLDB versions; walk base classes explicitly, mirroring the working
# gdb _base_cast/_member in Seele.py.
child = valobj.GetChildMemberWithName(name)
if child.IsValid():
return child
t = valobj.GetType()
seen = set()
while t.IsValid() and t not in seen:
seen.add(t)
for i in range(t.GetNumBases()):
base = t.GetBaseClass(i)
if base.IsValid():
sub = valobj.GetBaseClassWithName(base.GetName())
if sub.IsValid():
child = sub.GetChildMemberWithName(name)
if child.IsValid():
return child
t = t.GetBaseClass(0) if t.GetNumBases() > 0 else None
return None
def Array_SummaryProvider(valobj, internal_dict):
size = valobj.GetChildMemberWithName('arraySize').GetValueAsUnsigned(0)
return f"Array(size={size})"
@@ -65,8 +87,8 @@ class ListSyntheticProvider:
return True
def Tree_SummaryProvider(valobj, internal_dict):
size = valobj.GetChildMemberWithName('_size').GetValueAsUnsigned(0)
return f"Tree(size={size})"
size = _member(valobj, '_size')
return f"Tree(size={size.GetValueAsUnsigned(0) if size and size.IsValid() else '?'})"
class TreeSyntheticProvider:
def __init__(self, valobj, internal_dict):
@@ -87,28 +109,35 @@ class TreeSyntheticProvider:
return None
# Collect all nodes via in-order traversal, then return the one at `index`
nodes = []
self._collect(self.root, nodes)
if self.root and self.root.IsValid():
self._collect(self.root, nodes)
if index >= len(nodes):
return None
return nodes[index].GetChildMemberWithName('data')
data = nodes[index].GetChildMemberWithName('data')
return data if data.IsValid() else None
def _collect(self, node, out):
if not node.IsValid():
return
self._collect(node.GetChildMemberWithName('leftChild'), out)
left = node.GetChildMemberWithName('leftChild')
if left.IsValid():
self._collect(left.Dereference(), out)
out.append(node)
self._collect(node.GetChildMemberWithName('rightChild'), out)
right = node.GetChildMemberWithName('rightChild')
if right.IsValid():
self._collect(right.Dereference(), out)
def update(self):
self.root = self.valobj.GetChildMemberWithName('root')
self.size = self.valobj.GetChildMemberWithName('_size').GetValueAsUnsigned(0)
self.root = _member(self.valobj, 'root')
size = _member(self.valobj, '_size')
self.size = size.GetValueAsUnsigned(0) if size and size.IsValid() else 0
def has_children(self):
return True
return self.size > 0
def Set_SummaryProvider(valobj, internal_dict):
size = valobj.GetChildMemberWithName('_size').GetValueAsUnsigned(0)
return f"Set(size={size})"
size = _member(valobj, '_size')
return f"Set(size={size.GetValueAsUnsigned(0) if size and size.IsValid() else '?'})"
class SetSyntheticProvider:
def __init__(self, valobj, internal_dict):
@@ -128,28 +157,39 @@ class SetSyntheticProvider:
if index < 0 or index >= self.size:
return None
nodes = []
self._collect(self.root, nodes)
# Start from pseudoRoot: the splay tree's actual structure is
# connected via pseudoRoot.leftChild, not the `root` pointer.
if self.pseudoRoot and self.pseudoRoot.IsValid():
left = self.pseudoRoot.GetChildMemberWithName('leftChild')
if left.IsValid():
self._collect(left.Dereference(), nodes)
if index >= len(nodes):
return None
return nodes[index].GetChildMemberWithName('data')
data = nodes[index].GetChildMemberWithName('data')
return data if data.IsValid() else None
def _collect(self, node, out):
if not node.IsValid():
return
self._collect(node.GetChildMemberWithName('leftChild'), out)
left = node.GetChildMemberWithName('leftChild')
if left.IsValid():
self._collect(left.Dereference(), out)
out.append(node)
self._collect(node.GetChildMemberWithName('rightChild'), out)
right = node.GetChildMemberWithName('rightChild')
if right.IsValid():
self._collect(right.Dereference(), out)
def update(self):
self.root = self.valobj.GetChildMemberWithName('root')
self.size = self.valobj.GetChildMemberWithName('_size').GetValueAsUnsigned(0)
self.pseudoRoot = _member(self.valobj, 'pseudoRoot')
size = _member(self.valobj, '_size')
self.size = size.GetValueAsUnsigned(0) if size and size.IsValid() else 0
def has_children(self):
return True
return self.size > 0
def Map_SummaryProvider(valobj, internal_dict):
size = valobj.GetChildMemberWithName('_size').GetValueAsUnsigned(0)
return f"Map(size={size})"
size = _member(valobj, '_size')
return f"Map(size={size.GetValueAsUnsigned(0) if size and size.IsValid() else '?'})"
class MapSyntheticProvider:
def __init__(self, valobj, internal_dict):
@@ -169,24 +209,37 @@ class MapSyntheticProvider:
if index < 0 or index >= self.size:
return None
nodes = []
self._collect(self.root, nodes)
# Start from pseudoRoot: the splay tree's actual structure is
# connected via pseudoRoot.leftChild, not the `root` pointer.
if self.pseudoRoot and self.pseudoRoot.IsValid():
left = self.pseudoRoot.GetChildMemberWithName('leftChild')
if left.IsValid():
self._collect(left.Dereference(), nodes)
if index >= len(nodes):
return None
return nodes[index].GetChildMemberWithName('data')
# Map stores Pair<K, V> in node.data; return the pair so the
# debugger can show key/value members (Pair is a plain struct).
data = nodes[index].GetChildMemberWithName('data')
return data if data.IsValid() else None
def _collect(self, node, out):
if not node.IsValid():
return
self._collect(node.GetChildMemberWithName('leftChild'), out)
left = node.GetChildMemberWithName('leftChild')
if left.IsValid():
self._collect(left.Dereference(), out)
out.append(node)
self._collect(node.GetChildMemberWithName('rightChild'), out)
right = node.GetChildMemberWithName('rightChild')
if right.IsValid():
self._collect(right.Dereference(), out)
def update(self):
self.root = self.valobj.GetChildMemberWithName('root')
self.size = self.valobj.GetChildMemberWithName('_size').GetValueAsUnsigned(0)
self.pseudoRoot = _member(self.valobj, 'pseudoRoot')
size = _member(self.valobj, '_size')
self.size = size.GetValueAsUnsigned(0) if size and size.IsValid() else 0
def has_children(self):
return True
return self.size > 0
def Vector_SummaryProvider(valobj, internal_dict):
# Get the template parameters to determine vector length
+3 -1
View File
@@ -359,7 +359,9 @@ struct CookTorrance : IBRDF
const float MAX_REFLECTION_LOD = 4;
float3 prefilteredColor = pLightEnv.prefilteredMap.SampleLevel(pLightEnv.irradianceSampler, r, roughness * MAX_REFLECTION_LOD).xyz;
float2 envBRDF = pLightEnv.brdfLUT.Sample(pLightEnv.lutSampler, float2(max(dot(normal, viewDir_WS), 0), roughness)).rg;
// brdfLUT has no mip levels and is indexed analytically (N·V, roughness) with no screen
// derivatives, so implicit LOD is unavailable (GLCompute/Ray) and meaningless: use level 0.
float2 envBRDF = pLightEnv.brdfLUT.SampleLevel(pLightEnv.lutSampler, float2(max(dot(normal, viewDir_WS), 0), roughness), 0).rg;
float3 specular = prefilteredColor * (F * envBRDF.x + envBRDF.y);
return (k_d * diffuse + specular) * ambientOcclusion;
+1 -1
View File
@@ -68,7 +68,7 @@ struct DrawCallOffsets
};
#ifdef RAY_TRACING
// Shader record buffers are accessed via a different mechanism and don't use descriptor set bindings
layout(set = 15, shaderRecordEXT)
layout(shaderRecordEXT)
#else
layout(push_constant)
#endif
+2 -1
View File
@@ -7,6 +7,7 @@ void miss(inout RayPayload p)
// p.shading.normal = -WorldRayDirection();
// p.shading.normalLight = -WorldRayDirection();
// p.material.color = float4(0, 0, 0, 0);
p.light = float3(pRayTracingParams.skyBox.Sample(pRayTracingParams.skyBoxSampler, WorldRayDirection()).xyz);
// miss shaders (GLCompute) can't do ImplicitLod (mip) sampling; use a fixed level
p.light = float3(pRayTracingParams.skyBox.SampleLevel(pRayTracingParams.skyBoxSampler, WorldRayDirection(), 0).xyz);
p.hit = false;
}
+3 -2
View File
@@ -1,12 +1,13 @@
#include "PlayView.h"
#include "Scene/Scene.h"
#include "Window/Window.h"
#include <fmt/format.h>
#include <fstream>
using namespace Seele;
PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath, bool useMeshCulling)
: GameView(graphics, window, createInfo, dllPath) {
PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, PScene scene, const ViewportCreateInfo& createInfo, bool useMeshCulling)
: GameView(graphics, window, scene, createInfo) {
getGlobals().useDepthCulling = useMeshCulling;
renderTimestamp = graphics->createTimestampQuery(2, "RenderTimestamp");
queryThread = std::thread([&]() {
+1 -1
View File
@@ -4,7 +4,7 @@
namespace Seele {
class PlayView : public GameView {
public:
PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath, bool useMeshCulling);
PlayView(Gfx::PGraphics graphics, PWindow window, PScene scene, const ViewportCreateInfo& createInfo, bool useMeshCulling);
virtual ~PlayView();
virtual void beginUpdate() override;
virtual void update() override;
+15 -6
View File
@@ -3,7 +3,9 @@
#include "Graphics/StaticMeshVertexData.h"
#include "Graphics/Vulkan/Graphics.h"
#include "PlayView.h"
#include "Window/WindowManager.h"
#include "Scene/Scene.h"
#include "System/SystemGraph.h"
#include "Window/Application.h"
#include <fmt/core.h>
#include <random>
@@ -32,7 +34,14 @@ int main(int argc, char** argv) {
vd->init(graphics);
getGlobals().useRayTracing = true;
OWindowManager windowManager = new WindowManager();
// 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 = {
@@ -41,7 +50,7 @@ int main(int argc, char** argv) {
.title = "Benchmark",
.preferredFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB,
};
auto window = windowManager->addWindow(graphics, mainWindowInfo);
auto window = application->addWindow(graphics, mainWindowInfo);
ViewportCreateInfo sceneViewInfo = {
.dimensions =
{
@@ -49,11 +58,11 @@ int main(int argc, char** argv) {
.offset = {0, 0},
},
};
OGameView sceneView = new PlayView(graphics, window, sceneViewInfo, binaryPath.generic_string(), useDepthCulling);
OGameView sceneView = new PlayView(graphics, window, application->scene(), sceneViewInfo, useDepthCulling);
sceneView->setFocused();
while (windowManager->isActive()) {
windowManager->render();
while (application->isActive()) {
application->render();
}
graphics->waitDeviceIdle();
vd->destroy();
+1 -1
View File
@@ -6,7 +6,7 @@
#include "Graphics/Shader.h"
#include "Material/Material.h"
#include "Material/ShaderExpression.h"
#include "Window/WindowManager.h"
#include "Window/Application.h"
#include <fmt/core.h>
#include <fstream>
#include <iostream>
+3 -1
View File
@@ -3,4 +3,6 @@ add_subdirectory(Window/)
target_sources(Editor
PRIVATE
main.cpp)
main.cpp
ComponentRegistry.h
ComponentRegistry.cpp)
+2 -2
View File
@@ -7,8 +7,8 @@
using namespace Seele;
using namespace Seele::Editor;
PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::filesystem::path dllPath)
: GameView(graphics, window, createInfo, dllPath) {}
PlayView::PlayView(Gfx::PGraphics graphics, PWindow window, PScene scene, const ViewportCreateInfo& createInfo)
: GameView(graphics, window, scene, createInfo) {}
PlayView::~PlayView() {}
+1 -1
View File
@@ -5,7 +5,7 @@ namespace Seele {
namespace Editor {
class PlayView : public GameView {
public:
PlayView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::filesystem::path dllPath);
PlayView(Gfx::PGraphics graphics, PWindow window, PScene scene, const ViewportCreateInfo& createInfo);
virtual ~PlayView();
virtual void beginUpdate() override;
virtual void update() override;
+25 -18
View File
@@ -10,8 +10,13 @@
#include "Material/Material.h"
#include "Graphics/Vulkan/Graphics.h"
#include "Graphics/StaticMeshVertexData.h"
#include "System/SystemGraph.h"
#include "Window/PlayView.h"
#include "Window/WindowManager.h"
#include "System/CameraUpdater.h"
#include "System/FluidUpdater.h"
#include "System/LightGather.h"
#include "System/MeshUpdater.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"
@@ -136,7 +141,12 @@ int main(int argc, char** argv) {
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
vd->init(graphics);
OWindowManager windowManager = new WindowManager();
// 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{
@@ -171,19 +181,16 @@ int main(int argc, char** argv) {
.title = "SeeleEngine",
.preferredFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB,
};
auto window = windowManager->addWindow(graphics, mainWindowInfo);
// ViewportCreateInfo sceneViewInfo = {
// .dimensions =
// {
// .size = {1920, 1080},
// .offset = {0, 0},
// },
// };
// OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath);
// sceneView->setFocused();
// The windowed editor path has no pre-existing scene; the InspectorView's entity
// pane needs one to enumerate. Create a fresh Scene on the live (windowed) device.
OScene scene = new Scene(graphics);
auto window = application->addWindow(graphics, mainWindowInfo);
ViewportCreateInfo sceneViewInfo = {
.dimensions =
{
.size = {1920, 1080},
.offset = {0, 0},
},
};
OGameView sceneView = new Editor::PlayView(graphics, window, application->scene(), sceneViewInfo);
sceneView->setFocused();
OInspectorView inspectorView = new Editor::InspectorView(graphics, window,
ViewportCreateInfo{
.dimensions =
@@ -192,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();
+1 -1
View File
@@ -9,7 +9,7 @@
#include "FontAsset.h"
#include "Graphics/Graphics.h"
#include "Graphics/Mesh.h"
#include "Window/WindowManager.h"
#include "Window/Application.h"
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
+1 -1
View File
@@ -1,7 +1,7 @@
#include "TextureAsset.h"
#include "Graphics/Graphics.h"
#include "Graphics/Texture.h"
#include "Window/WindowManager.h"
#include "Window/Application.h"
#include "ktx.h"
#include <iostream>
@@ -142,6 +142,10 @@ void UIPass::createRenderPass() {
passSize = UVector2(viewport->getWidth(), viewport->getHeight());
createRenderPass();
}
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
.colorAttachments = {colorAttachment},
.depthAttachment = depthAttachment,
};
Array<Gfx::SubPassDependency> dependency = {
{
.srcSubpass = ~0U,
+1 -1
View File
@@ -1009,7 +1009,7 @@ void Graphics::pickPhysicalDevice() {
shaderFloatControls = true;
}
}
rayTracingEnabled = rayTracingPipelineSupport && accelerationStructureSupport && hostOperationsSupport && deviceAddressSupport &&
rayTracingEnabled = false && rayTracingPipelineSupport && accelerationStructureSupport && hostOperationsSupport && deviceAddressSupport &&
descriptorIndexingSupport && spirv14Support && shaderFloatControls;
}
+1 -1
View File
@@ -4,7 +4,7 @@
#include "Graphics/Shader.h"
#include "MaterialInstance.h"
#include "Serialization/Serialization.h"
#include "Window/WindowManager.h"
#include "Window/Application.h"
#include <fstream>
using namespace Seele;
+96
View File
@@ -0,0 +1,96 @@
#include "Application.h"
#include "Graphics/Enums.h"
#include "Graphics/Graphics.h"
#include "System/SystemGraph.h"
#include "Scene/Scene.h"
#include "Game.h"
#include "System/KeyboardInput.h"
#include "System/FluidUpdater.h"
#include "System/LightGather.h"
#include "System/MeshUpdater.h"
#include "System/CameraUpdater.h"
#ifdef WIN32
#include "Platform/Windows/GameInterface.h"
#else
#include "Platform/Linux/GameInterface.h"
#endif
using namespace Seele;
namespace {
// Library extension per platform (mirrors the editor's old binary-path logic).
const char* libraryExtension() {
#ifdef WIN32
return "dll";
#elif __APPLE__
return "dylib";
#else
return "so";
#endif
}
} // namespace
Application::Application() : graphics(nullptr), scene_(nullptr), graph_(nullptr), gameInterface(nullptr) {}
Application::~Application() {
if (gameInterface != nullptr) {
delete gameInterface; // ~GameInterface dlclose()s + destroys the Game instance
gameInterface = nullptr;
}
// `scene_` and `graph_` are OwningPtr: their destructors free the Scene and
// (via the moved-in OSystemBase entries) every System.
}
void Application::loadGame(Gfx::PGraphics graphics, const std::filesystem::path& sourcePath, const std::string& gameName) {
this->graphics = graphics;
// The world is created exactly once, owned by the Application. `loadGame` is
// the single setup point (called once per process) — no null guards needed.
scene_ = OScene(new Scene(graphics));
graph_ = OSystemGraph(new SystemGraph());
// Resolve the game binary and load it (dlopen) once.
std::filesystem::path binaryPath = sourcePath / "bin" / (gameName + "." + libraryExtension());
GameInterface* interface = new GameInterface(binaryPath);
interface->reload();
gameInterface = interface;
// Let the game populate the Scene + SystemGraph we own, then append the
// editor's own systems. This used to live in the editor's main.cpp; it now
// lives here so the world has a single owner and a single setup point.
interface->getGame()->setupScene(scene_, graph_);
graph_->addSystem(new System::KeyboardInput(scene_));
graph_->addSystem(new System::FluidUpdater(scene_));
graph_->addSystem(new System::LightGather(scene_));
graph_->addSystem(new System::MeshUpdater(scene_));
graph_->addSystem(new System::CameraUpdater(scene_));
}
OWindow Application::addWindow(Gfx::PGraphics graphics, const WindowCreateInfo& createInfo) {
OWindow window = new Window(this, graphics->createWindow(createInfo));
windows.add(window);
return window;
}
void Application::attachWorld(OScene scene, OSystemGraph graph) {
// Worldless hosts (benchmark) build their own world and hand ownership in;
// the Application's owning members take it via move so the frame loop can
// step it and the views can render it.
scene_ = std::move(scene);
graph_ = std::move(graph);
}
void Application::render() {
// Step the world exactly ONCE per frame, independent of how many windows
// are open. The old code re-ran the graph inside the per-window loop, which
// double-simulated with two windows. Views below only render the world.
graph_->run(Gfx::getCurrentFrameDelta());
for (auto& window : windows) {
window->pollInputs();
if (window->isPaused())
continue;
window->render();
}
}
void Application::notifyWindowClosed(PWindow window) { windows.remove(window); }
+59
View File
@@ -0,0 +1,59 @@
#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
+3 -3
View File
@@ -6,8 +6,8 @@ target_sources(Engine
View.cpp
Window.cpp
Window.h
WindowManager.h
WindowManager.cpp)
Application.h
Application.cpp)
target_sources(Engine
PUBLIC FILE_SET HEADERS
@@ -15,4 +15,4 @@ target_sources(Engine
GameView.h
View.h
Window.h
WindowManager.h)
Application.h)
+4 -25
View File
@@ -4,25 +4,18 @@
#include "Graphics/RenderPass/BasePass.h"
#include "Graphics/RenderPass/CachedDepthPass.h"
#include "Graphics/RenderPass/DepthCullingPass.h"
#include "Graphics/RenderPass/FluidRenderPass.h"
#include "Graphics/RenderPass/LightCullingPass.h"
#include "Graphics/RenderPass/RayTracingPass.h"
#include "Graphics/RenderPass/ShadowPass.h"
#include "Graphics/RenderPass/SimulationComputePass.h"
#include "Graphics/RenderPass/SurfaceExtractPass.h"
#include "Graphics/RenderPass/ToneMappingPass.h"
#include "Graphics/RenderPass/VisibilityPass.h"
#include "System/CameraUpdater.h"
#include "System/FluidUpdater.h"
#include "System/LightGather.h"
#include "System/MeshUpdater.h"
#include "Window/Window.h"
#include "Scene/LightEnvironment.h"
using namespace Seele;
GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::filesystem::path dllPath)
: View(graphics, window, createInfo, "Game"), graphics(graphics), scene(new Scene(graphics)), gameInterface(dllPath) {
GameView::GameView(Gfx::PGraphics graphics, PWindow window, PScene scene, const ViewportCreateInfo& createInfo)
: View(graphics, window, createInfo, "Game"), graphics(graphics), scene(scene) {
reloadGame();
renderGraph.addPass(new CachedDepthPass(graphics, scene));
renderGraph.addPass(new DepthCullingPass(graphics, scene));
@@ -56,7 +49,6 @@ void GameView::update() {
for (VertexData* vd : VertexData::getList()) {
vd->resetMeshData();
}
systemGraph->run(updateTime);
scene->update(updateTime);
for (VertexData* vd : VertexData::getList()) {
vd->createDescriptors();
@@ -94,29 +86,16 @@ void GameView::applyArea(URect) {
}
void GameView::reloadGame() {
gameInterface.reload();
systemGraph = new SystemGraph();
gameInterface.getGame()->setupScene(scene, systemGraph);
System::OKeyboardInput keyInput = new System::KeyboardInput(scene);
keyboardSystem = keyInput;
systemGraph->addSystem(std::move(keyInput));
systemGraph->addSystem(new System::FluidUpdater(scene));
systemGraph->addSystem(new System::LightGather(scene));
systemGraph->addSystem(new System::MeshUpdater(scene));
systemGraph->addSystem(new System::CameraUpdater(scene));
}
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifierFlags modifier) {
keyboardSystem->keyCallback(code, action, modifier);
}
void GameView::mouseMoveCallback(double xPos, double yPos) { keyboardSystem->mouseCallback(xPos, yPos); }
void GameView::mouseMoveCallback(double xPos, double yPos) { }
void GameView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifierFlags modifier) {
keyboardSystem->mouseButtonCallback(button, action, modifier);
}
void GameView::scrollCallback(double xScroll, double yScroll) { keyboardSystem->scrollCallback(xScroll, yScroll); }
void GameView::scrollCallback(double xScroll, double yScroll) { }
void GameView::fileCallback(int, const char**) {}
+2 -4
View File
@@ -12,7 +12,7 @@
namespace Seele {
class GameView : public View {
public:
GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::filesystem::path dllPath);
GameView(Gfx::PGraphics graphics, PWindow window, PScene scene, const ViewportCreateInfo& createInfo);
virtual ~GameView();
virtual void beginUpdate() override;
virtual void update() override;
@@ -26,12 +26,10 @@ class GameView : public View {
protected:
virtual void applyArea(URect rect) override;
Gfx::PGraphics graphics;
OScene scene;
GameInterface gameInterface;
PScene scene;
RenderGraph renderGraph;
RenderGraph rayTracingGraph;
OSystemGraph systemGraph;
System::PKeyboardInput keyboardSystem;
float updateTime = 0;
+2 -2
View File
@@ -1,10 +1,10 @@
#include "Window.h"
#include "WindowManager.h"
#include "Application.h"
#include <functional>
using namespace Seele;
Window::Window(PWindowManager owner, Gfx::OWindow handle) : owner(owner), gfxHandle(std::move(handle)) {
Window::Window(PApplication owner, Gfx::OWindow handle) : owner(owner), gfxHandle(std::move(handle)) {
gfxHandle->setResizeCallback([this](uint32 w, uint32 h) { onResize(w, h); });
}
+3 -3
View File
@@ -3,11 +3,11 @@
#include "View.h"
namespace Seele {
DECLARE_REF(WindowManager)
DECLARE_REF(Application)
// The logical window, with the graphics proxy
class Window {
public:
Window(PWindowManager owner, Gfx::OWindow handle);
Window(PApplication owner, Gfx::OWindow handle);
~Window();
void show() { gfxHandle->show(); }
void addView(PView view);
@@ -20,7 +20,7 @@ class Window {
constexpr bool shouldClose() const { return gfxHandle->shouldClose(); }
protected:
PWindowManager owner;
PApplication owner;
Array<PView> views;
Gfx::OWindow gfxHandle;
};
-25
View File
@@ -1,25 +0,0 @@
#include "WindowManager.h"
#include "Graphics/Graphics.h"
using namespace Seele;
WindowManager::WindowManager() {}
WindowManager::~WindowManager() {}
OWindow WindowManager::addWindow(Gfx::PGraphics graphics, const WindowCreateInfo& createInfo) {
OWindow window = new Window(this, graphics->createWindow(createInfo));
windows.add(window);
return window;
}
void WindowManager::render() {
for (auto& window : windows) {
window->pollInputs();
if (window->isPaused())
continue;
window->render();
}
}
void WindowManager::notifyWindowClosed(PWindow window) { windows.remove(window); }
-20
View File
@@ -1,20 +0,0 @@
#pragma once
#include "Containers/Array.h"
#include "Window.h"
namespace Seele {
DECLARE_NAME_REF(Gfx, Graphics)
class WindowManager {
public:
WindowManager();
~WindowManager();
OWindow addWindow(Gfx::PGraphics graphics, const WindowCreateInfo& createInfo);
void render();
void notifyWindowClosed(PWindow window);
bool isActive() const { return getGlobals().running && windows.size(); }
private:
Array<PWindow> windows;
};
DEFINE_REF(WindowManager)
} // namespace Seele