Basic graphics structure

This commit is contained in:
HOEGLER Stefan
2020-03-02 19:07:49 +01:00
parent a14237d6ce
commit 4c2535931e
16 changed files with 137 additions and 48 deletions
+1
View File
@@ -47,6 +47,7 @@ include_directories(src/Engine)
add_definitions(${GLM_DEFINITIONS})
add_definitions(${Vulkan_DEFINITIONS})
add_definitions(${Boost_DEFINITIONS})
add_compile_definitions(GLFW_WINDOWS)
add_executable(SeeleEngine "")
add_subdirectory(src/)
target_link_libraries(SeeleEngine ${Boost_LIBRARIES})
+3 -3
View File
@@ -16,7 +16,7 @@ namespace Seele
: allocated(DEFAULT_ALLOC_SIZE)
, arraySize(0)
{
_data = new T[DEFAULT_ALLOC_SIZE];
_data = (T*)malloc(DEFAULT_ALLOC_SIZE * sizeof(T));
refreshIterators();
}
Array(size_t size, T value = T())
@@ -110,10 +110,10 @@ namespace Seele
if (arraySize == allocated)
{
allocated += DEFAULT_ALLOC_SIZE;
T* tempArray = new T[allocated];
void* tempArray = malloc(sizeof(T) * allocated);
std::memcpy(tempArray, _data, arraySize * sizeof(T));
delete _data;
_data = tempArray;
_data = (T*)tempArray;
}
_data[arraySize++] = item;
refreshIterators();
+3
View File
@@ -2,7 +2,10 @@ target_sources(SeeleEngine
PRIVATE
Graphics.h
Graphics.cpp
RenderPath.h
RenderPath.cpp
View.h
View.cpp
WindowManager.h
WindowManager.cpp
Window.h
+6 -12
View File
@@ -1,28 +1,22 @@
#pragma once
#include "MinimalEngine.h"
#include "GraphicsResources.h"
#include "Containers/Array.h"
namespace Seele {
class Window;
class Graphics
{
public:
static Graphics& getInstance()
{
static Graphics instance;
return instance;
}
void init(GraphicsInitializer initializer);
void beginFrame();
void endFrame();
virtual void init(GraphicsInitializer initializer) = 0;
virtual void beginFrame() = 0;
virtual void endFrame() = 0;
virtual void* createWindow(const WindowCreateInfo& createInfo) = 0;
//Singleton
private:
Graphics();
Graphics(Graphics const&) = delete;
void operator=(Graphics const&) = delete;
~Graphics();
friend class Window;
};
}
+8
View File
@@ -6,4 +6,12 @@ namespace Seele
{
const char* windowLayoutFile;
};
struct WindowCreateInfo
{
int32 width;
int32 height;
const char* title;
bool bFullscreen;
};
}
+6
View File
@@ -0,0 +1,6 @@
#include "RenderPath.h"
Seele::RenderPath::RenderPath(Graphics* graphics)
: graphics(graphics)
{
}
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#include "Graphics.h"
namespace Seele
{
//A renderpath is a general Renderer for a view.
class RenderPath
{
public:
RenderPath(Graphics* graphics);
virtual ~RenderPath();
virtual void init() = 0;
virtual void beginFrame() = 0;
virtual void render() = 0;
virtual void endFrame() = 0;
protected:
Graphics* graphics;
};
DECLARE_REF(RenderPath);
}
+10
View File
@@ -0,0 +1,10 @@
#include "View.h"
Seele::View::View(PSection owner)
: owner(owner)
{
}
Seele::View::~View()
{
}
+15 -7
View File
@@ -1,10 +1,18 @@
#pragma once
#include "Window.h"
// A view is a part of the window, which can be anything from a viewport to an editor
class View
#include "RenderPath.h"
namespace Seele
{
public:
private:
Window::Section* owner;
};
// A view is a part of the window, which can be anything from a viewport to an editor
class View
{
public:
View(PSection owner);
~View();
private:
PRenderPath renderer;
PSection owner;
};
DECLARE_REF(View)
}
@@ -0,0 +1,4 @@
target_sources(SeeleEngine
PRIVATE
VulkanGraphics.h
VulkanGraphics.cpp)
@@ -0,0 +1,18 @@
#include "VulkanGraphics.h"
void Seele::VulkanGraphics::init(GraphicsInitializer initializer)
{
}
void Seele::VulkanGraphics::beginFrame()
{
}
void Seele::VulkanGraphics::endFrame()
{
}
void* Seele::VulkanGraphics::createWindow(const WindowCreateInfo& createInfo)
{
return nullptr;
}
@@ -0,0 +1,14 @@
#include "Graphics/Graphics.h"
namespace Seele
{
class VulkanGraphics : public Graphics
{
public:
// Inherited via Graphics
virtual void init(GraphicsInitializer initializer) override;
virtual void beginFrame() override;
virtual void endFrame() override;
virtual void* createWindow(const WindowCreateInfo& createInfo) override;
};
}
+6 -4
View File
@@ -1,12 +1,14 @@
#include "Window.h"
#include "Graphics.h"
#include <iostream>
#include "Vulkan/VulkanGraphics.h"
Seele::Window::Window(const WindowCreateInfo& createInfo)
: width(createInfo.width)
, height(createInfo.height)
, windowHandle(nullptr)
{
graphics = new VulkanGraphics();
}
Seele::Window::~Window()
{
}
}
+18 -19
View File
@@ -1,33 +1,30 @@
#pragma once
#include "MinimalEngine.h"
namespace Seele {
struct WindowCreateInfo
// A window is divided into 5 sections, using a border layout
// +--------------TOP------------------+
// | |
// L R
// E I
// F CENTER G
// T H
// | T
// +-------------BOTTOM----------------+
// In every section, there can be any number
// of views, when there are multiple, they stack to tabs
struct Section
{
int32 width;
int32 height;
const char* title;
};
DECLARE_REF(Section)
class Window
{
public:
Window(const WindowCreateInfo& createInfo);
~Window();
private:
// A window is divided into 5 sections, using a border layout
// +--------------TOP------------------+
// | |
// L R
// E I
// F CENTER G
// T H
// | T
// +-------------BOTTOM----------------+
// In every section, there can be any number
// of views, when there are multiple, they stack to tabs
struct Section
{
};
void* windowHandle;
Section top;
Section bot;
Section left;
@@ -35,5 +32,7 @@ namespace Seele {
Section center;
uint32 width;
uint32 height;
Graphics* graphics;
};
DECLARE_REF(Window)
}
+1 -1
View File
@@ -11,6 +11,6 @@ namespace Seele
WindowManager(GraphicsInitializer initializer);
~WindowManager();
private:
Array<RefPtr<Window>> windows;
Array<PWindow> windows;
};
}
+5 -2
View File
@@ -4,6 +4,10 @@
#include <memory>
#include <atomic>
#define DECLARE_REF(x) class x; \
typedef RefPtr<x> P##x; \
typedef UniquePtr<x> UP##x;
namespace Seele
{
typedef uint64_t uint64;
@@ -16,7 +20,6 @@ namespace Seele
typedef int16_t int16;
typedef int8_t int8;
template<typename T>
class RefPtr
{
@@ -35,7 +38,7 @@ namespace Seele
if (this != &other)
{
object->removeRef();
object = other->object;
object = other.object;
object->addRef();
}
return *this;