Formatted EVERYTHING
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
#include "GameView.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Window/Window.h"
|
||||
#include "Component/KeyboardInput.h"
|
||||
#include "Actor/CameraActor.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Component/KeyboardInput.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/RenderPass/BasePass.h"
|
||||
#include "Graphics/RenderPass/CachedDepthPass.h"
|
||||
#include "Graphics/RenderPass/DebugPass.h"
|
||||
#include "Graphics/RenderPass/DepthPrepass.h"
|
||||
#include "Graphics/RenderPass/LightCullingPass.h"
|
||||
#include "Graphics/RenderPass/SkyboxRenderPass.h"
|
||||
#include "Graphics/RenderPass/VisibilityPass.h"
|
||||
#include "System/CameraUpdater.h"
|
||||
#include "System/LightGather.h"
|
||||
#include "System/MeshUpdater.h"
|
||||
#include "System/CameraUpdater.h"
|
||||
#include "Graphics/RenderPass/CachedDepthPass.h"
|
||||
#include "Graphics/RenderPass/DepthPrepass.h"
|
||||
#include "Graphics/RenderPass/VisibilityPass.h"
|
||||
#include "Graphics/RenderPass/LightCullingPass.h"
|
||||
#include "Graphics/RenderPass/BasePass.h"
|
||||
#include "Graphics/RenderPass/SkyboxRenderPass.h"
|
||||
#include "Graphics/RenderPass/DebugPass.h"
|
||||
#include "Window/Window.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -22,12 +22,8 @@ bool useViewCulling = false;
|
||||
bool useLightCulling = false;
|
||||
bool resetVisibility = false;
|
||||
|
||||
|
||||
GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo, std::string dllPath)
|
||||
: View(graphics, window, createInfo, "Game")
|
||||
, scene(new Scene(graphics))
|
||||
, gameInterface(dllPath)
|
||||
{
|
||||
GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath)
|
||||
: View(graphics, window, createInfo, "Game"), scene(new Scene(graphics)), gameInterface(dllPath) {
|
||||
reloadGame();
|
||||
renderGraph.addPass(new CachedDepthPass(graphics, scene));
|
||||
renderGraph.addPass(new DepthPrepass(graphics, scene));
|
||||
@@ -35,31 +31,23 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate
|
||||
renderGraph.addPass(new LightCullingPass(graphics, scene));
|
||||
renderGraph.addPass(new BasePass(graphics, scene));
|
||||
renderGraph.addPass(new DebugPass(graphics, scene));
|
||||
//renderGraph.addPass(new SkyboxRenderPass(graphics, scene));
|
||||
// renderGraph.addPass(new SkyboxRenderPass(graphics, scene));
|
||||
renderGraph.setViewport(viewport);
|
||||
renderGraph.createRenderPass();
|
||||
}
|
||||
|
||||
GameView::~GameView()
|
||||
{
|
||||
|
||||
}
|
||||
GameView::~GameView() {}
|
||||
|
||||
void GameView::beginUpdate()
|
||||
{
|
||||
}
|
||||
void GameView::beginUpdate() {}
|
||||
|
||||
void GameView::update()
|
||||
{
|
||||
void GameView::update() {
|
||||
static auto startTime = std::chrono::high_resolution_clock::now();
|
||||
for (VertexData* vd : VertexData::getList())
|
||||
{
|
||||
for (VertexData* vd : VertexData::getList()) {
|
||||
vd->resetMeshData();
|
||||
}
|
||||
systemGraph->run(updateTime);
|
||||
scene->update(updateTime);
|
||||
for (VertexData* vd : VertexData::getList())
|
||||
{
|
||||
for (VertexData* vd : VertexData::getList()) {
|
||||
vd->createDescriptors();
|
||||
}
|
||||
scene->getLightEnvironment()->commit();
|
||||
@@ -69,33 +57,24 @@ void GameView::update()
|
||||
startTime = endTime;
|
||||
}
|
||||
|
||||
void GameView::commitUpdate()
|
||||
{
|
||||
}
|
||||
void GameView::commitUpdate() {}
|
||||
|
||||
void GameView::prepareRender()
|
||||
{
|
||||
}
|
||||
void GameView::prepareRender() {}
|
||||
|
||||
void GameView::render()
|
||||
{
|
||||
void GameView::render() {
|
||||
Component::Camera cam;
|
||||
scene->view<Component::Camera>([&cam](Component::Camera& c) {
|
||||
if (c.mainCamera)
|
||||
if (c.mainCamera)
|
||||
cam = c;
|
||||
});
|
||||
renderGraph.render(cam);
|
||||
}
|
||||
|
||||
void GameView::applyArea(URect)
|
||||
{
|
||||
renderGraph.setViewport(viewport);
|
||||
}
|
||||
void GameView::applyArea(URect) { renderGraph.setViewport(viewport); }
|
||||
|
||||
void GameView::reloadGame()
|
||||
{
|
||||
void GameView::reloadGame() {
|
||||
gameInterface.reload();
|
||||
|
||||
|
||||
systemGraph = new SystemGraph();
|
||||
gameInterface.getGame()->setupScene(scene, systemGraph);
|
||||
System::OKeyboardInput keyInput = new System::KeyboardInput(scene);
|
||||
@@ -106,45 +85,31 @@ void GameView::reloadGame()
|
||||
systemGraph->addSystem(new System::CameraUpdater(scene));
|
||||
}
|
||||
|
||||
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier)
|
||||
{
|
||||
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier) {
|
||||
keyboardSystem->keyCallback(code, action, modifier);
|
||||
if (code == KeyCode::KEY_P && action == InputAction::RELEASE)
|
||||
{
|
||||
if (code == KeyCode::KEY_P && action == InputAction::RELEASE) {
|
||||
usePositionOnly = !usePositionOnly;
|
||||
std::cout << "Use Pos only " << usePositionOnly << std::endl;
|
||||
}
|
||||
if (code == KeyCode::KEY_O && action == InputAction::RELEASE)
|
||||
{
|
||||
if (code == KeyCode::KEY_O && action == InputAction::RELEASE) {
|
||||
useViewCulling = !useViewCulling;
|
||||
std::cout << "Use View Culling " << useViewCulling << std::endl;
|
||||
}
|
||||
if (code == KeyCode::KEY_L && action == InputAction::RELEASE)
|
||||
{
|
||||
if (code == KeyCode::KEY_L && action == InputAction::RELEASE) {
|
||||
useLightCulling = !useLightCulling;
|
||||
std::cout << "Use Light Culling " << useLightCulling << std::endl;
|
||||
}
|
||||
if (code == KeyCode::KEY_R && action == InputAction::RELEASE)
|
||||
{
|
||||
if (code == KeyCode::KEY_R && action == InputAction::RELEASE) {
|
||||
resetVisibility = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GameView::mouseMoveCallback(double xPos, double yPos)
|
||||
{
|
||||
keyboardSystem->mouseCallback(xPos, yPos);
|
||||
}
|
||||
void GameView::mouseMoveCallback(double xPos, double yPos) { keyboardSystem->mouseCallback(xPos, yPos); }
|
||||
|
||||
void GameView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier)
|
||||
{
|
||||
void GameView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) {
|
||||
keyboardSystem->mouseButtonCallback(button, action, modifier);
|
||||
}
|
||||
|
||||
void GameView::scrollCallback(double xScroll, double yScroll)
|
||||
{
|
||||
keyboardSystem->scrollCallback(xScroll, yScroll);
|
||||
}
|
||||
void GameView::scrollCallback(double xScroll, double yScroll) { keyboardSystem->scrollCallback(xScroll, yScroll); }
|
||||
|
||||
void GameView::fileCallback(int, const char**)
|
||||
{
|
||||
}
|
||||
void GameView::fileCallback(int, const char**) {}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
#pragma once
|
||||
#include "Window/View.h"
|
||||
#include "Scene/Scene.h"
|
||||
#include "System/KeyboardInput.h"
|
||||
#include "Window/View.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "Platform/Windows/GameInterface.h" // TODO
|
||||
#else
|
||||
#include "Platform/Linux/GameInterface.h"
|
||||
#endif
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class GameView : public View
|
||||
{
|
||||
namespace Seele {
|
||||
class GameView : public View {
|
||||
public:
|
||||
GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo, std::string dllPath);
|
||||
GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string dllPath);
|
||||
virtual ~GameView();
|
||||
virtual void beginUpdate() override;
|
||||
virtual void update() override;
|
||||
@@ -38,7 +37,7 @@ namespace Seele
|
||||
virtual void mouseMoveCallback(double xPos, double yPos) override;
|
||||
virtual void mouseButtonCallback(Seele::MouseButton button, Seele::InputAction action, Seele::KeyModifier modifier) override;
|
||||
virtual void scrollCallback(double xOffset, double yOffset) override;
|
||||
virtual void fileCallback(int count, const char **paths) override;
|
||||
};
|
||||
DEFINE_REF(GameView)
|
||||
virtual void fileCallback(int count, const char** paths) override;
|
||||
};
|
||||
DEFINE_REF(GameView)
|
||||
} // namespace Seele
|
||||
|
||||
+14
-27
@@ -1,37 +1,24 @@
|
||||
#include "View.h"
|
||||
#include "Window.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Window.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &viewportInfo, std::string name)
|
||||
: graphics(graphics)
|
||||
, createInfo(viewportInfo)
|
||||
, owner(window)
|
||||
, name(name)
|
||||
{
|
||||
viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo);
|
||||
owner->addView(this);
|
||||
setFocused();
|
||||
View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& viewportInfo, std::string name)
|
||||
: graphics(graphics), createInfo(viewportInfo), owner(window), name(name) {
|
||||
viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo);
|
||||
owner->addView(this);
|
||||
setFocused();
|
||||
}
|
||||
|
||||
View::~View()
|
||||
{
|
||||
View::~View() {}
|
||||
|
||||
void View::resize(URect area) {
|
||||
createInfo.dimensions = area;
|
||||
viewport = graphics->createViewport(owner->getGfxHandle(), createInfo);
|
||||
applyArea(area);
|
||||
}
|
||||
|
||||
void View::resize(URect area)
|
||||
{
|
||||
createInfo.dimensions = area;
|
||||
viewport = graphics->createViewport(owner->getGfxHandle(), createInfo);
|
||||
applyArea(area);
|
||||
}
|
||||
void View::setFocused() { owner->setFocused(this); }
|
||||
|
||||
void View::setFocused()
|
||||
{
|
||||
owner->setFocused(this);
|
||||
}
|
||||
|
||||
const std::string& View::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
const std::string& View::getName() { return name; }
|
||||
|
||||
+28
-30
@@ -1,41 +1,39 @@
|
||||
#pragma once
|
||||
#include "Graphics/RenderPass/RenderGraph.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Seele {
|
||||
DECLARE_REF(Window)
|
||||
// A view is a part of the window, which can be anything from a scene viewport to an inspector
|
||||
class View
|
||||
{
|
||||
public:
|
||||
View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo, std::string name);
|
||||
virtual ~View();
|
||||
|
||||
virtual void beginUpdate() = 0;
|
||||
virtual void update() = 0;
|
||||
virtual void commitUpdate() = 0;
|
||||
class View {
|
||||
public:
|
||||
View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo, std::string name);
|
||||
virtual ~View();
|
||||
|
||||
virtual void prepareRender() = 0;
|
||||
virtual void render() = 0;
|
||||
void resize(URect area);
|
||||
void setFocused();
|
||||
virtual void beginUpdate() = 0;
|
||||
virtual void update() = 0;
|
||||
virtual void commitUpdate() = 0;
|
||||
|
||||
const std::string& getName();
|
||||
virtual void prepareRender() = 0;
|
||||
virtual void render() = 0;
|
||||
void resize(URect area);
|
||||
void setFocused();
|
||||
|
||||
protected:
|
||||
virtual void applyArea(URect area) = 0;
|
||||
Gfx::PGraphics graphics;
|
||||
Gfx::OViewport viewport;
|
||||
ViewportCreateInfo createInfo;
|
||||
PWindow owner;
|
||||
std::string name;
|
||||
|
||||
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) = 0;
|
||||
virtual void mouseMoveCallback(double xPos, double yPos) = 0;
|
||||
virtual void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) = 0;
|
||||
virtual void scrollCallback(double xOffset, double yOffset) = 0;
|
||||
virtual void fileCallback(int count, const char** paths) = 0;
|
||||
friend class Window;
|
||||
const std::string& getName();
|
||||
|
||||
protected:
|
||||
virtual void applyArea(URect area) = 0;
|
||||
Gfx::PGraphics graphics;
|
||||
Gfx::OViewport viewport;
|
||||
ViewportCreateInfo createInfo;
|
||||
PWindow owner;
|
||||
std::string name;
|
||||
|
||||
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) = 0;
|
||||
virtual void mouseMoveCallback(double xPos, double yPos) = 0;
|
||||
virtual void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) = 0;
|
||||
virtual void scrollCallback(double xOffset, double yOffset) = 0;
|
||||
virtual void fileCallback(int count, const char** paths) = 0;
|
||||
friend class Window;
|
||||
};
|
||||
|
||||
DEFINE_REF(View)
|
||||
|
||||
@@ -4,32 +4,19 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Window::Window(PWindowManager owner, Gfx::OWindow handle)
|
||||
: owner(owner)
|
||||
, gfxHandle(std::move(handle))
|
||||
{
|
||||
gfxHandle->setResizeCallback([this](uint32 w, uint32 h) {onResize(w, h); });
|
||||
Window::Window(PWindowManager owner, Gfx::OWindow handle) : owner(owner), gfxHandle(std::move(handle)) {
|
||||
gfxHandle->setResizeCallback([this](uint32 w, uint32 h) { onResize(w, h); });
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
}
|
||||
Window::~Window() {}
|
||||
|
||||
void Window::addView(PView view)
|
||||
{
|
||||
views.add(view);
|
||||
}
|
||||
void Window::addView(PView view) { views.add(view); }
|
||||
|
||||
void Window::pollInputs()
|
||||
{
|
||||
gfxHandle->pollInput();
|
||||
}
|
||||
void Window::pollInputs() { gfxHandle->pollInput(); }
|
||||
|
||||
void Window::render()
|
||||
{
|
||||
void Window::render() {
|
||||
gfxHandle->beginFrame();
|
||||
for(auto& view : views)
|
||||
{
|
||||
for (auto& view : views) {
|
||||
view->beginUpdate();
|
||||
view->update();
|
||||
view->commitUpdate();
|
||||
@@ -39,16 +26,13 @@ void Window::render()
|
||||
gfxHandle->endFrame();
|
||||
}
|
||||
|
||||
Gfx::PWindow Window::getGfxHandle()
|
||||
{
|
||||
return gfxHandle;
|
||||
}
|
||||
|
||||
void Window::setFocused(PView view)
|
||||
{
|
||||
Gfx::PWindow Window::getGfxHandle() { return gfxHandle; }
|
||||
|
||||
void Window::setFocused(PView view) {
|
||||
auto keyFunction = std::bind(&View::keyCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
auto mouseMoveFunction = std::bind(&View::mouseMoveCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2);
|
||||
auto mouseButtonFunction = std::bind(&View::mouseButtonCallback, view.getHandle() , std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
auto mouseButtonFunction =
|
||||
std::bind(&View::mouseButtonCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
auto scrollFunction = std::bind(&View::scrollCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2);
|
||||
auto fileFunction = std::bind(&View::fileCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2);
|
||||
gfxHandle->setKeyCallback(keyFunction);
|
||||
@@ -56,19 +40,15 @@ void Window::setFocused(PView view)
|
||||
gfxHandle->setMouseButtonCallback(mouseButtonFunction);
|
||||
gfxHandle->setScrollCallback(scrollFunction);
|
||||
gfxHandle->setFileCallback(fileFunction);
|
||||
gfxHandle->setCloseCallback([this](){
|
||||
owner->notifyWindowClosed(this);
|
||||
});
|
||||
gfxHandle->setCloseCallback([this]() { owner->notifyWindowClosed(this); });
|
||||
}
|
||||
|
||||
void Window::onResize(uint32 width, uint32 height)
|
||||
{
|
||||
for (auto& view : views)
|
||||
{
|
||||
void Window::onResize(uint32 width, uint32 height) {
|
||||
for (auto& view : views) {
|
||||
// TODO: some sort of layouting algorithm should do this
|
||||
view->resize(URect{
|
||||
.size = UVector2(width, height),
|
||||
.offset = UVector2(0, 0),
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
#pragma once
|
||||
#include "View.h"
|
||||
#include "Graphics/RenderTarget.h"
|
||||
#include "View.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Seele {
|
||||
DECLARE_REF(WindowManager)
|
||||
// The logical window, with the graphics proxy
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
class Window {
|
||||
public:
|
||||
Window(PWindowManager owner, Gfx::OWindow handle);
|
||||
~Window();
|
||||
void addView(PView view);
|
||||
@@ -17,11 +15,9 @@ public:
|
||||
Gfx::PWindow getGfxHandle();
|
||||
void setFocused(PView view);
|
||||
void onResize(uint32 width, uint32 height);
|
||||
constexpr bool isPaused() const
|
||||
{
|
||||
return gfxHandle->isPaused();
|
||||
}
|
||||
protected:
|
||||
constexpr bool isPaused() const { return gfxHandle->isPaused(); }
|
||||
|
||||
protected:
|
||||
PWindowManager owner;
|
||||
Array<PView> views;
|
||||
Gfx::OWindow gfxHandle;
|
||||
|
||||
@@ -3,25 +3,18 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
WindowManager::WindowManager()
|
||||
{
|
||||
}
|
||||
WindowManager::WindowManager() {}
|
||||
|
||||
WindowManager::~WindowManager()
|
||||
{
|
||||
}
|
||||
WindowManager::~WindowManager() {}
|
||||
|
||||
OWindow WindowManager::addWindow(Gfx::PGraphics graphics, const WindowCreateInfo &createInfo)
|
||||
{
|
||||
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)
|
||||
{
|
||||
void WindowManager::render() {
|
||||
for (auto& window : windows) {
|
||||
window->pollInputs();
|
||||
if (window->isPaused())
|
||||
continue;
|
||||
@@ -29,7 +22,4 @@ void WindowManager::render()
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::notifyWindowClosed(PWindow window)
|
||||
{
|
||||
windows.remove(window);
|
||||
}
|
||||
void WindowManager::notifyWindowClosed(PWindow window) { windows.remove(window); }
|
||||
|
||||
@@ -2,24 +2,19 @@
|
||||
#include "Containers/Array.h"
|
||||
#include "Window.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
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 windows.size();
|
||||
}
|
||||
class WindowManager {
|
||||
public:
|
||||
WindowManager();
|
||||
~WindowManager();
|
||||
OWindow addWindow(Gfx::PGraphics graphics, const WindowCreateInfo& createInfo);
|
||||
void render();
|
||||
void notifyWindowClosed(PWindow window);
|
||||
bool isActive() const { return windows.size(); }
|
||||
|
||||
private:
|
||||
Array<PWindow> windows;
|
||||
private:
|
||||
Array<PWindow> windows;
|
||||
};
|
||||
DEFINE_REF(WindowManager)
|
||||
} // namespace Seele
|
||||
Reference in New Issue
Block a user