Added scene renderer
This commit is contained in:
@@ -2,10 +2,16 @@ target_sources(SeeleEngine
|
||||
PRIVATE
|
||||
Graphics.h
|
||||
Graphics.cpp
|
||||
RenderCore.h
|
||||
RenderCore.cpp
|
||||
RenderPath.h
|
||||
RenderPath.cpp
|
||||
SceneRenderPath.h
|
||||
SceneRenderPath.cpp
|
||||
View.h
|
||||
View.cpp
|
||||
SceneView.h
|
||||
SceneView.cpp
|
||||
WindowManager.h
|
||||
WindowManager.cpp
|
||||
Window.h
|
||||
|
||||
@@ -9,12 +9,10 @@ namespace Seele {
|
||||
{
|
||||
public:
|
||||
virtual void init(GraphicsInitializer initializer) = 0;
|
||||
virtual void beginFrame() = 0;
|
||||
virtual void endFrame() = 0;
|
||||
virtual void beginFrame(void* windowHandle) = 0;
|
||||
virtual void endFrame(void* windowHandle) = 0;
|
||||
virtual void* createWindow(const WindowCreateInfo& createInfo) = 0;
|
||||
|
||||
//Singleton
|
||||
private:
|
||||
protected:
|
||||
Graphics();
|
||||
~Graphics();
|
||||
friend class Window;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "MinimalEngine.h"
|
||||
namespace Seele
|
||||
{
|
||||
struct GraphicsInitializer
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "RenderCore.h"
|
||||
|
||||
Seele::RenderCore::RenderCore()
|
||||
{
|
||||
windowManager = new WindowManager();
|
||||
}
|
||||
|
||||
Seele::RenderCore::~RenderCore()
|
||||
{
|
||||
}
|
||||
|
||||
void Seele::RenderCore::init()
|
||||
{
|
||||
WindowCreateInfo mainWindowInfo;
|
||||
mainWindowInfo.title = "SeeleEngine";
|
||||
mainWindowInfo.width = 1280;
|
||||
mainWindowInfo.height = 720;
|
||||
mainWindowInfo.bFullscreen = false;
|
||||
windowManager->addWindow(mainWindowInfo);
|
||||
}
|
||||
|
||||
void Seele::RenderCore::renderLoop()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
windowManager->beginFrame();
|
||||
windowManager->endFrame();
|
||||
}
|
||||
}
|
||||
|
||||
void Seele::RenderCore::shutdown()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "WindowManager.h"
|
||||
namespace Seele
|
||||
{
|
||||
class RenderCore
|
||||
{
|
||||
public:
|
||||
RenderCore();
|
||||
~RenderCore();
|
||||
void init();
|
||||
void renderLoop();
|
||||
void shutdown();
|
||||
private:
|
||||
PWindowManager windowManager;
|
||||
};
|
||||
}
|
||||
@@ -4,3 +4,7 @@ Seele::RenderPath::RenderPath(Graphics* graphics)
|
||||
: graphics(graphics)
|
||||
{
|
||||
}
|
||||
|
||||
Seele::RenderPath::~RenderPath()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -8,12 +8,14 @@ namespace Seele
|
||||
public:
|
||||
RenderPath(Graphics* graphics);
|
||||
virtual ~RenderPath();
|
||||
virtual void applyArea(Rect area) = 0;
|
||||
virtual void init() = 0;
|
||||
virtual void beginFrame() = 0;
|
||||
virtual void render() = 0;
|
||||
virtual void endFrame() = 0;
|
||||
protected:
|
||||
Graphics* graphics;
|
||||
Rect area;
|
||||
};
|
||||
DECLARE_REF(RenderPath);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "RenderPath.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class SceneRenderPath : public RenderPath
|
||||
{
|
||||
public:
|
||||
SceneRenderPath();
|
||||
virtual ~SceneRenderPath();
|
||||
virtual void applyArea(Rect area) override;
|
||||
virtual void init() override;
|
||||
virtual void beginFrame() override;
|
||||
virtual void render() override;
|
||||
virtual void endFrame() override;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "SceneView.h"
|
||||
#include "SceneRenderPath.h"
|
||||
|
||||
Seele::SceneView::SceneView()
|
||||
{
|
||||
}
|
||||
|
||||
Seele::SceneView::~SceneView()
|
||||
{
|
||||
}
|
||||
|
||||
void Seele::SceneView::initRenderer()
|
||||
{
|
||||
renderer = new SceneRenderPath();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "View.h"
|
||||
namespace Seele
|
||||
{
|
||||
class SceneView : public View
|
||||
{
|
||||
public:
|
||||
SceneView();
|
||||
~SceneView();
|
||||
virtual void initRenderer() override;
|
||||
};
|
||||
}
|
||||
@@ -1,10 +1,24 @@
|
||||
#include "View.h"
|
||||
|
||||
Seele::View::View(PSection owner)
|
||||
: owner(owner)
|
||||
Seele::View::View()
|
||||
{
|
||||
}
|
||||
|
||||
Seele::View::~View()
|
||||
{
|
||||
}
|
||||
|
||||
void Seele::View::beginFrame()
|
||||
{
|
||||
renderer->beginFrame();
|
||||
}
|
||||
|
||||
void Seele::View::endFrame()
|
||||
{
|
||||
renderer->endFrame();
|
||||
}
|
||||
|
||||
void Seele::View::applyArea(Rect area)
|
||||
{
|
||||
renderer->applyArea(area);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include "Window.h"
|
||||
#include "RenderPath.h"
|
||||
namespace Seele
|
||||
{
|
||||
@@ -7,11 +6,14 @@ namespace Seele
|
||||
class View
|
||||
{
|
||||
public:
|
||||
View(PSection owner);
|
||||
~View();
|
||||
private:
|
||||
View();
|
||||
virtual ~View();
|
||||
virtual void initRenderer() = 0;
|
||||
void beginFrame();
|
||||
void endFrame();
|
||||
void applyArea(Rect area);
|
||||
protected:
|
||||
PRenderPath renderer;
|
||||
PSection owner;
|
||||
};
|
||||
|
||||
DECLARE_REF(View)
|
||||
|
||||
@@ -1,18 +1,35 @@
|
||||
#include "VulkanGraphics.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
void Seele::VulkanGraphics::init(GraphicsInitializer initializer)
|
||||
{
|
||||
}
|
||||
|
||||
void Seele::VulkanGraphics::beginFrame()
|
||||
void Seele::VulkanGraphics::beginFrame(void* windowHandle)
|
||||
{
|
||||
GLFWwindow* window = static_cast<GLFWwindow*>(windowHandle);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
void Seele::VulkanGraphics::endFrame()
|
||||
void Seele::VulkanGraphics::endFrame(void* windowHandle)
|
||||
{
|
||||
GLFWwindow* window = static_cast<GLFWwindow*>(windowHandle);
|
||||
|
||||
}
|
||||
|
||||
void* Seele::VulkanGraphics::createWindow(const WindowCreateInfo& createInfo)
|
||||
{
|
||||
return nullptr;
|
||||
GLFWwindow* window = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, createInfo.bFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
|
||||
return window;
|
||||
}
|
||||
|
||||
Seele::VulkanGraphics::VulkanGraphics()
|
||||
{
|
||||
glfwInit();
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
}
|
||||
|
||||
Seele::VulkanGraphics::~VulkanGraphics()
|
||||
{
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,12 @@ namespace Seele
|
||||
public:
|
||||
// Inherited via Graphics
|
||||
virtual void init(GraphicsInitializer initializer) override;
|
||||
virtual void beginFrame() override;
|
||||
virtual void endFrame() override;
|
||||
virtual void beginFrame(void* windowHandle) override;
|
||||
virtual void endFrame(void* windowHandle) override;
|
||||
virtual void* createWindow(const WindowCreateInfo& createInfo) override;
|
||||
protected:
|
||||
VulkanGraphics();
|
||||
virtual ~VulkanGraphics();
|
||||
friend class Window;
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,29 @@
|
||||
#include "Window.h"
|
||||
#include "Vulkan/VulkanGraphics.h"
|
||||
#include "SceneView.h"
|
||||
|
||||
Seele::Window::Window(const WindowCreateInfo& createInfo)
|
||||
: width(createInfo.width)
|
||||
, height(createInfo.height)
|
||||
, windowHandle(nullptr)
|
||||
{
|
||||
center = new Section();
|
||||
center->resizeArea(Rect(1, 1, 0, 0));
|
||||
center->addView(new SceneView());
|
||||
graphics = new VulkanGraphics();
|
||||
windowHandle = graphics->createWindow(createInfo);
|
||||
}
|
||||
|
||||
Seele::Window::~Window()
|
||||
{
|
||||
}
|
||||
|
||||
void Seele::Window::beginFrame()
|
||||
{
|
||||
graphics->beginFrame(windowHandle);
|
||||
center->beginFrame();
|
||||
}
|
||||
|
||||
void Seele::Window::endFrame()
|
||||
{
|
||||
graphics->endFrame(windowHandle);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
#include "GraphicsResources.h"
|
||||
#include "View.h"
|
||||
namespace Seele {
|
||||
|
||||
// A window is divided into 5 sections, using a border layout
|
||||
@@ -13,23 +14,52 @@ namespace Seele {
|
||||
// +-------------BOTTOM----------------+
|
||||
// In every section, there can be any number
|
||||
// of views, when there are multiple, they stack to tabs
|
||||
struct Section
|
||||
class Section
|
||||
{
|
||||
public:
|
||||
Section()
|
||||
{}
|
||||
void resizeArea(Rect area)
|
||||
{
|
||||
this->area = area;
|
||||
}
|
||||
void beginFrame()
|
||||
{
|
||||
views[0]->beginFrame();
|
||||
}
|
||||
void endFrame()
|
||||
{
|
||||
views[0]->endFrame();
|
||||
}
|
||||
void addView(PView view)
|
||||
{
|
||||
view->applyArea(area);
|
||||
views.add(view);
|
||||
}
|
||||
void clearViews(PView view)
|
||||
{
|
||||
views.clear();
|
||||
}
|
||||
void removeView(PView view)
|
||||
{
|
||||
views.remove(views.find(view));
|
||||
}
|
||||
private:
|
||||
Rect area;
|
||||
Array<PView> views;
|
||||
};
|
||||
DECLARE_REF(Section)
|
||||
|
||||
class Graphics;
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
Window(const WindowCreateInfo& createInfo);
|
||||
~Window();
|
||||
void beginFrame();
|
||||
void endFrame();
|
||||
private:
|
||||
void* windowHandle;
|
||||
Section top;
|
||||
Section bot;
|
||||
Section left;
|
||||
Section right;
|
||||
Section center;
|
||||
PSection center;
|
||||
uint32 width;
|
||||
uint32 height;
|
||||
Graphics* graphics;
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
#include "WindowManager.h"
|
||||
|
||||
Seele::WindowManager::WindowManager(GraphicsInitializer initializer)
|
||||
Seele::WindowManager::WindowManager()
|
||||
{
|
||||
//TODO Parse layout file
|
||||
WindowCreateInfo mainWindowInfo;
|
||||
mainWindowInfo.title = "SeeleEngine";
|
||||
mainWindowInfo.width = 1280;
|
||||
mainWindowInfo.height = 720;
|
||||
Window* mainWindow = new Window(mainWindowInfo);
|
||||
windows.add(mainWindow);
|
||||
}
|
||||
|
||||
Seele::WindowManager::~WindowManager()
|
||||
{
|
||||
}
|
||||
|
||||
void Seele::WindowManager::addWindow(const WindowCreateInfo& createInfo)
|
||||
{
|
||||
PWindow window = new Window(createInfo);
|
||||
windows.add(window);
|
||||
}
|
||||
|
||||
void Seele::WindowManager::beginFrame()
|
||||
{
|
||||
for (auto window : windows)
|
||||
{
|
||||
window->beginFrame();
|
||||
}
|
||||
}
|
||||
|
||||
void Seele::WindowManager::endFrame()
|
||||
{
|
||||
for (auto window : windows)
|
||||
{
|
||||
window->endFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,13 @@ namespace Seele
|
||||
class WindowManager
|
||||
{
|
||||
public:
|
||||
WindowManager(GraphicsInitializer initializer);
|
||||
WindowManager();
|
||||
~WindowManager();
|
||||
void addWindow(const WindowCreateInfo& createInfo);
|
||||
void beginFrame();
|
||||
void endFrame();
|
||||
private:
|
||||
Array<PWindow> windows;
|
||||
};
|
||||
DECLARE_REF(WindowManager);
|
||||
}
|
||||
Reference in New Issue
Block a user