Graphics is now a global object, instead of a per-window one
This commit is contained in:
@@ -26,6 +26,7 @@ namespace Seele
|
|||||||
, arraySize(size)
|
, arraySize(size)
|
||||||
{
|
{
|
||||||
_data = (T*)malloc(size * sizeof(T));
|
_data = (T*)malloc(size * sizeof(T));
|
||||||
|
assert(_data != nullptr);
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
_data[i] = value;
|
_data[i] = value;
|
||||||
@@ -38,10 +39,10 @@ namespace Seele
|
|||||||
{
|
{
|
||||||
_data = (T*)malloc(init.size() * sizeof(T));
|
_data = (T*)malloc(init.size() * sizeof(T));
|
||||||
auto it = init.begin();
|
auto it = init.begin();
|
||||||
for (size_t i = 0; i < init.size(); i++)
|
for (size_t i = 0; it != init.end(); i++, it++)
|
||||||
{
|
{
|
||||||
|
assert(i < init.size());
|
||||||
_data[i] = *it;
|
_data[i] = *it;
|
||||||
it++;
|
|
||||||
}
|
}
|
||||||
refreshIterators();
|
refreshIterators();
|
||||||
}
|
}
|
||||||
@@ -50,6 +51,7 @@ namespace Seele
|
|||||||
, arraySize(other.arraySize)
|
, arraySize(other.arraySize)
|
||||||
{
|
{
|
||||||
_data = (T*)malloc(other.allocated * sizeof(T));
|
_data = (T*)malloc(other.allocated * sizeof(T));
|
||||||
|
assert(_data != nullptr);
|
||||||
std::memcpy(_data, other._data, sizeof(T) * allocated);
|
std::memcpy(_data, other._data, sizeof(T) * allocated);
|
||||||
refreshIterators();
|
refreshIterators();
|
||||||
}
|
}
|
||||||
@@ -174,6 +176,7 @@ namespace Seele
|
|||||||
{
|
{
|
||||||
allocated += DEFAULT_ALLOC_SIZE;
|
allocated += DEFAULT_ALLOC_SIZE;
|
||||||
void* tempArray = malloc(sizeof(T) * allocated);
|
void* tempArray = malloc(sizeof(T) * allocated);
|
||||||
|
assert(tempArray != nullptr);
|
||||||
std::memcpy(tempArray, _data, arraySize * sizeof(T));
|
std::memcpy(tempArray, _data, arraySize * sizeof(T));
|
||||||
memset(tempArray, 0, sizeof(T) * allocated);
|
memset(tempArray, 0, sizeof(T) * allocated);
|
||||||
delete _data;
|
delete _data;
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ namespace Seele {
|
|||||||
class Graphics
|
class Graphics
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Graphics();
|
||||||
|
~Graphics();
|
||||||
virtual void init(GraphicsInitializer initializer) = 0;
|
virtual void init(GraphicsInitializer initializer) = 0;
|
||||||
virtual void beginFrame(void* windowHandle) = 0;
|
virtual void beginFrame(void* windowHandle) = 0;
|
||||||
virtual void endFrame(void* windowHandle) = 0;
|
virtual void endFrame(void* windowHandle) = 0;
|
||||||
virtual void* createWindow(const WindowCreateInfo& createInfo) = 0;
|
virtual void* createWindow(const WindowCreateInfo& createInfo) = 0;
|
||||||
protected:
|
protected:
|
||||||
Graphics();
|
|
||||||
~Graphics();
|
|
||||||
friend class Window;
|
friend class Window;
|
||||||
};
|
};
|
||||||
DEFINE_REF(Graphics);
|
DEFINE_REF(Graphics);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace Seele
|
|||||||
const char* windowLayoutFile;
|
const char* windowLayoutFile;
|
||||||
const char* applicationName;
|
const char* applicationName;
|
||||||
const char* engineName;
|
const char* engineName;
|
||||||
|
void* windowHandle;
|
||||||
/**
|
/**
|
||||||
* layers defines the enabled Vulkan layers used in the instance,
|
* layers defines the enabled Vulkan layers used in the instance,
|
||||||
* if ENABLE_VALIDATION is defined, standard validation is already enabled
|
* if ENABLE_VALIDATION is defined, standard validation is already enabled
|
||||||
@@ -34,6 +35,7 @@ namespace Seele
|
|||||||
, layers{ "VK_LAYER_LUNARG_standard_validation" }
|
, layers{ "VK_LAYER_LUNARG_standard_validation" }
|
||||||
, instanceExtensions{}
|
, instanceExtensions{}
|
||||||
, deviceExtensions{ "VK_KHR_swapchain" }
|
, deviceExtensions{ "VK_KHR_swapchain" }
|
||||||
|
, windowHandle(nullptr)
|
||||||
{}
|
{}
|
||||||
GraphicsInitializer(const GraphicsInitializer& other)
|
GraphicsInitializer(const GraphicsInitializer& other)
|
||||||
: applicationName(other.applicationName)
|
: applicationName(other.applicationName)
|
||||||
@@ -44,12 +46,14 @@ namespace Seele
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
DECLARE_REF(Graphics);
|
||||||
struct WindowCreateInfo
|
struct WindowCreateInfo
|
||||||
{
|
{
|
||||||
int32 width;
|
int32 width;
|
||||||
int32 height;
|
int32 height;
|
||||||
const char* title;
|
const char* title;
|
||||||
bool bFullscreen;
|
bool bFullscreen;
|
||||||
|
PGraphics graphics;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderCommandBase
|
class RenderCommandBase
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "RenderPath.h"
|
#include "RenderPath.h"
|
||||||
|
|
||||||
Seele::RenderPath::RenderPath(Graphics* graphics)
|
Seele::RenderPath::RenderPath(PGraphics graphics)
|
||||||
: graphics(graphics)
|
: graphics(graphics)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Seele
|
|||||||
class RenderPath
|
class RenderPath
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderPath(Graphics* graphics);
|
RenderPath(PGraphics graphics);
|
||||||
virtual ~RenderPath();
|
virtual ~RenderPath();
|
||||||
virtual void applyArea(Rect area) = 0;
|
virtual void applyArea(Rect area) = 0;
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
@@ -14,7 +14,7 @@ namespace Seele
|
|||||||
virtual void render() = 0;
|
virtual void render() = 0;
|
||||||
virtual void endFrame() = 0;
|
virtual void endFrame() = 0;
|
||||||
protected:
|
protected:
|
||||||
Graphics* graphics;
|
PGraphics graphics;
|
||||||
Rect area;
|
Rect area;
|
||||||
};
|
};
|
||||||
DEFINE_REF(RenderPath);
|
DEFINE_REF(RenderPath);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "SceneRenderPath.h"
|
#include "SceneRenderPath.h"
|
||||||
|
|
||||||
Seele::SceneRenderPath::SceneRenderPath(Graphics* graphics)
|
Seele::SceneRenderPath::SceneRenderPath(PGraphics graphics)
|
||||||
: RenderPath(graphics)
|
: RenderPath(graphics)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Seele
|
|||||||
class SceneRenderPath : public RenderPath
|
class SceneRenderPath : public RenderPath
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SceneRenderPath(Graphics* graphics);
|
SceneRenderPath(PGraphics graphics);
|
||||||
virtual ~SceneRenderPath();
|
virtual ~SceneRenderPath();
|
||||||
virtual void applyArea(Rect area) override;
|
virtual void applyArea(Rect area) override;
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "SceneView.h"
|
#include "SceneView.h"
|
||||||
#include "SceneRenderPath.h"
|
#include "SceneRenderPath.h"
|
||||||
|
|
||||||
Seele::SceneView::SceneView(Graphics* graphics)
|
Seele::SceneView::SceneView(PGraphics graphics)
|
||||||
: View(graphics)
|
: View(graphics)
|
||||||
{
|
{
|
||||||
renderer = new SceneRenderPath(graphics);
|
renderer = new SceneRenderPath(graphics);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Seele
|
|||||||
class SceneView : public View
|
class SceneView : public View
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SceneView(Graphics* graphics);
|
SceneView(PGraphics graphics);
|
||||||
~SceneView();
|
~SceneView();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "View.h"
|
#include "View.h"
|
||||||
|
|
||||||
Seele::View::View(Graphics* graphics)
|
Seele::View::View(PGraphics graphics)
|
||||||
: graphics(graphics)
|
: graphics(graphics)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,18 @@
|
|||||||
#include "RenderPath.h"
|
#include "RenderPath.h"
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
class Graphics;
|
DECLARE_REF(Graphics);
|
||||||
// A view is a part of the window, which can be anything from a viewport to an editor
|
// A view is a part of the window, which can be anything from a viewport to an editor
|
||||||
class View
|
class View
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
View(Graphics* graphics);
|
View(PGraphics graphics);
|
||||||
virtual ~View();
|
virtual ~View();
|
||||||
void beginFrame();
|
void beginFrame();
|
||||||
void endFrame();
|
void endFrame();
|
||||||
void applyArea(Rect area);
|
void applyArea(Rect area);
|
||||||
protected:
|
protected:
|
||||||
Graphics* graphics;
|
PGraphics graphics;
|
||||||
PRenderPath renderer;
|
PRenderPath renderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,34 +4,27 @@
|
|||||||
#include "VulkanInitializer.h"
|
#include "VulkanInitializer.h"
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
|
||||||
|
Seele::VulkanGraphics::VulkanGraphics()
|
||||||
|
: callback(VK_NULL_HANDLE)
|
||||||
|
, handle(VK_NULL_HANDLE)
|
||||||
|
, instance(VK_NULL_HANDLE)
|
||||||
|
, physicalDevice(VK_NULL_HANDLE)
|
||||||
|
{
|
||||||
|
glfwInit();
|
||||||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
|
}
|
||||||
|
|
||||||
|
Seele::VulkanGraphics::~VulkanGraphics()
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
}
|
||||||
|
|
||||||
void Seele::VulkanGraphics::init(GraphicsInitializer initInfo)
|
void Seele::VulkanGraphics::init(GraphicsInitializer initInfo)
|
||||||
{
|
{
|
||||||
VkApplicationInfo appInfo = {};
|
initInstance(initInfo);
|
||||||
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
|
||||||
appInfo.pApplicationName = initInfo.applicationName;
|
|
||||||
appInfo.applicationVersion = VK_MAKE_VERSION(0, 0, 1);
|
|
||||||
appInfo.pEngineName = initInfo.engineName;
|
|
||||||
appInfo.engineVersion = VK_MAKE_VERSION(0, 0, 1);
|
|
||||||
appInfo.apiVersion = VK_API_VERSION_1_1;
|
|
||||||
|
|
||||||
VkInstanceCreateInfo info = {};
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
|
||||||
info.pApplicationInfo = &appInfo;
|
|
||||||
Array<const char*> extensions = getRequiredExtensions();
|
|
||||||
for (uint32 i = 0; i < initInfo.instanceExtensions.size(); ++i)
|
|
||||||
{
|
|
||||||
extensions.add(initInfo.instanceExtensions[i]);
|
|
||||||
}
|
|
||||||
info.enabledExtensionCount = (uint32)extensions.size();
|
|
||||||
info.ppEnabledExtensionNames = extensions.data();
|
|
||||||
#ifdef ENABLE_VALIDATION
|
|
||||||
info.enabledLayerCount = (uint32)initInfo.layers.size();
|
|
||||||
info.ppEnabledLayerNames = initInfo.layers.data();
|
|
||||||
#else
|
|
||||||
info.enabledLayerCount = 0;
|
|
||||||
#endif
|
|
||||||
VK_CHECK(vkCreateInstance(&info, nullptr, &instance));
|
|
||||||
setupDebugCallback();
|
setupDebugCallback();
|
||||||
|
pickPhysicalDevice();
|
||||||
allocator = new VulkanAllocator(this);
|
allocator = new VulkanAllocator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,17 +45,6 @@ void* Seele::VulkanGraphics::createWindow(const WindowCreateInfo& createInfo)
|
|||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
Seele::VulkanGraphics::VulkanGraphics()
|
|
||||||
{
|
|
||||||
glfwInit();
|
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
|
||||||
}
|
|
||||||
|
|
||||||
Seele::VulkanGraphics::~VulkanGraphics()
|
|
||||||
{
|
|
||||||
glfwTerminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
VkDevice Seele::VulkanGraphics::getDevice() const
|
VkDevice Seele::VulkanGraphics::getDevice() const
|
||||||
{
|
{
|
||||||
return handle;
|
return handle;
|
||||||
@@ -88,6 +70,34 @@ Seele::Array<const char*> Seele::VulkanGraphics::getRequiredExtensions()
|
|||||||
#endif // ENABLE_VALIDATION
|
#endif // ENABLE_VALIDATION
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
void Seele::VulkanGraphics::initInstance(GraphicsInitializer initInfo)
|
||||||
|
{
|
||||||
|
VkApplicationInfo appInfo = {};
|
||||||
|
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||||
|
appInfo.pApplicationName = initInfo.applicationName;
|
||||||
|
appInfo.applicationVersion = VK_MAKE_VERSION(0, 0, 1);
|
||||||
|
appInfo.pEngineName = initInfo.engineName;
|
||||||
|
appInfo.engineVersion = VK_MAKE_VERSION(0, 0, 1);
|
||||||
|
appInfo.apiVersion = VK_API_VERSION_1_1;
|
||||||
|
|
||||||
|
VkInstanceCreateInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||||
|
info.pApplicationInfo = &appInfo;
|
||||||
|
Array<const char*> extensions = getRequiredExtensions();
|
||||||
|
for (uint32 i = 0; i < initInfo.instanceExtensions.size(); ++i)
|
||||||
|
{
|
||||||
|
extensions.add(initInfo.instanceExtensions[i]);
|
||||||
|
}
|
||||||
|
info.enabledExtensionCount = (uint32)extensions.size();
|
||||||
|
info.ppEnabledExtensionNames = extensions.data();
|
||||||
|
#ifdef ENABLE_VALIDATION
|
||||||
|
info.enabledLayerCount = (uint32)initInfo.layers.size();
|
||||||
|
info.ppEnabledLayerNames = initInfo.layers.data();
|
||||||
|
#else
|
||||||
|
info.enabledLayerCount = 0;
|
||||||
|
#endif
|
||||||
|
VK_CHECK(vkCreateInstance(&info, nullptr, &instance));
|
||||||
|
}
|
||||||
void Seele::VulkanGraphics::setupDebugCallback()
|
void Seele::VulkanGraphics::setupDebugCallback()
|
||||||
{
|
{
|
||||||
VkDebugReportCallbackCreateInfoEXT createInfo =
|
VkDebugReportCallbackCreateInfoEXT createInfo =
|
||||||
@@ -95,4 +105,19 @@ void Seele::VulkanGraphics::setupDebugCallback()
|
|||||||
VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT);
|
VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT);
|
||||||
|
|
||||||
VK_CHECK(CreateDebugReportCallbackEXT(instance, &createInfo, nullptr, &callback));
|
VK_CHECK(CreateDebugReportCallbackEXT(instance, &createInfo, nullptr, &callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Seele::VulkanGraphics::pickPhysicalDevice()
|
||||||
|
{
|
||||||
|
uint32 physicalDeviceCount;
|
||||||
|
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, nullptr);
|
||||||
|
Array<VkPhysicalDevice> physicalDevices(physicalDeviceCount);
|
||||||
|
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices.data());
|
||||||
|
VkPhysicalDevice bestDevice;
|
||||||
|
uint32 deviceRating = 0;
|
||||||
|
for (auto physicalDevice : physicalDevices)
|
||||||
|
{
|
||||||
|
VkPhysicalDeviceProperties props;
|
||||||
|
vkGetPhysicalDeviceProperties(physicalDevice, &props);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,12 +19,15 @@ namespace Seele
|
|||||||
virtual void* createWindow(const WindowCreateInfo& createInfo) override;
|
virtual void* createWindow(const WindowCreateInfo& createInfo) override;
|
||||||
protected:
|
protected:
|
||||||
Array<const char*> getRequiredExtensions();
|
Array<const char*> getRequiredExtensions();
|
||||||
|
void initInstance(GraphicsInitializer initInfo);
|
||||||
void setupDebugCallback();
|
void setupDebugCallback();
|
||||||
|
void pickPhysicalDevice();
|
||||||
|
|
||||||
VkDevice handle;
|
VkDevice handle;
|
||||||
VkPhysicalDevice physicalDevice;
|
VkPhysicalDevice physicalDevice;
|
||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
VkDebugReportCallbackEXT callback;
|
VkDebugReportCallbackEXT callback;
|
||||||
|
Array<PVulkanViewport> viewports;
|
||||||
PVulkanAllocator allocator;
|
PVulkanAllocator allocator;
|
||||||
friend class Window;
|
friend class Window;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ VkDescriptorType Seele::cast(const SeDescriptorType& descriptorType)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return VK_DESCRIPTOR_TYPE_MAX_ENUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
SeDescriptorType Seele::cast(const VkDescriptorType& descriptorType)
|
SeDescriptorType Seele::cast(const VkDescriptorType& descriptorType)
|
||||||
@@ -71,6 +72,7 @@ SeDescriptorType Seele::cast(const VkDescriptorType& descriptorType)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return SE_DESCRIPTOR_TYPE_MAX_ENUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkShaderStageFlagBits Seele::cast(const SeShaderStageFlagBits& stage)
|
VkShaderStageFlagBits Seele::cast(const SeShaderStageFlagBits& stage)
|
||||||
@@ -113,6 +115,7 @@ VkShaderStageFlagBits Seele::cast(const SeShaderStageFlagBits& stage)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return VK_SHADER_STAGE_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SeShaderStageFlagBits Seele::cast(const VkShaderStageFlagBits& stage)
|
SeShaderStageFlagBits Seele::cast(const VkShaderStageFlagBits& stage)
|
||||||
@@ -154,4 +157,5 @@ SeShaderStageFlagBits Seele::cast(const VkShaderStageFlagBits& stage)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return SE_SHADER_STAGE_ALL;
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ namespace Seele
|
|||||||
public:
|
public:
|
||||||
VulkanDescriptorLayout(PVulkanGraphics graphics)
|
VulkanDescriptorLayout(PVulkanGraphics graphics)
|
||||||
: graphics(graphics)
|
: graphics(graphics)
|
||||||
|
, layoutHandle(VK_NULL_HANDLE)
|
||||||
{}
|
{}
|
||||||
virtual ~VulkanDescriptorLayout();
|
virtual ~VulkanDescriptorLayout();
|
||||||
virtual void create();
|
virtual void create();
|
||||||
@@ -30,6 +31,8 @@ namespace Seele
|
|||||||
public:
|
public:
|
||||||
VulkanPipelineLayout(PVulkanGraphics graphics)
|
VulkanPipelineLayout(PVulkanGraphics graphics)
|
||||||
: graphics(graphics)
|
: graphics(graphics)
|
||||||
|
, layoutHash(0)
|
||||||
|
, layoutHandle(VK_NULL_HANDLE)
|
||||||
{}
|
{}
|
||||||
virtual ~VulkanPipelineLayout();
|
virtual ~VulkanPipelineLayout();
|
||||||
virtual void create();
|
virtual void create();
|
||||||
@@ -53,7 +56,11 @@ namespace Seele
|
|||||||
class VulkanDescriptorSet : public DescriptorSet
|
class VulkanDescriptorSet : public DescriptorSet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VulkanDescriptorSet(PVulkanGraphics graphics, PVulkanDescriptorAllocator owner) : graphics(graphics), owner(owner) {}
|
VulkanDescriptorSet(PVulkanGraphics graphics, PVulkanDescriptorAllocator owner)
|
||||||
|
: graphics(graphics)
|
||||||
|
, owner(owner)
|
||||||
|
, setHandle(VK_NULL_HANDLE)
|
||||||
|
{}
|
||||||
virtual ~VulkanDescriptorSet();
|
virtual ~VulkanDescriptorSet();
|
||||||
virtual void updateBuffer(uint32_t binding, PUniformBuffer uniformBuffer);
|
virtual void updateBuffer(uint32_t binding, PUniformBuffer uniformBuffer);
|
||||||
virtual void updateBuffer(uint32_t binding, PStructuredBuffer uniformBuffer);
|
virtual void updateBuffer(uint32_t binding, PStructuredBuffer uniformBuffer);
|
||||||
@@ -132,4 +139,17 @@ namespace Seele
|
|||||||
VkSampler sampler;
|
VkSampler sampler;
|
||||||
};
|
};
|
||||||
DEFINE_REF(VulkanSamplerState);
|
DEFINE_REF(VulkanSamplerState);
|
||||||
|
|
||||||
|
class VulkanViewport : public Viewport
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
private:
|
||||||
|
uint32 sizeX;
|
||||||
|
uint32 sizeY;
|
||||||
|
uint32 offsetX;
|
||||||
|
uint32 offsetY;
|
||||||
|
VkSwapchainKHR swapchain;
|
||||||
|
void* windowHandle;
|
||||||
|
};
|
||||||
|
DECLARE_REF(VulkanViewport);
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Vulkan/VulkanGraphics.h"
|
|
||||||
#include "SceneView.h"
|
#include "SceneView.h"
|
||||||
|
|
||||||
Seele::Window::Window(const WindowCreateInfo& createInfo)
|
Seele::Window::Window(const WindowCreateInfo& createInfo)
|
||||||
: width(createInfo.width)
|
: width(createInfo.width)
|
||||||
, height(createInfo.height)
|
, height(createInfo.height)
|
||||||
{
|
{
|
||||||
graphics = new VulkanGraphics();
|
graphics = createInfo.graphics;
|
||||||
center = new Section();
|
center = new Section();
|
||||||
center->resizeArea(Rect(1, 1, 0, 0));
|
center->resizeArea(Rect(1, 1, 0, 0));
|
||||||
center->addView(new SceneView(graphics));
|
center->addView(new SceneView(graphics));
|
||||||
windowHandle = graphics->createWindow(createInfo);
|
windowHandle = graphics->createWindow(createInfo);
|
||||||
graphics->init(GraphicsInitializer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Seele::Window::~Window()
|
Seele::Window::~Window()
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace Seele {
|
|||||||
PSection center;
|
PSection center;
|
||||||
uint32 width;
|
uint32 width;
|
||||||
uint32 height;
|
uint32 height;
|
||||||
Graphics* graphics;
|
PGraphics graphics;
|
||||||
};
|
};
|
||||||
DEFINE_REF(Window)
|
DEFINE_REF(Window)
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
#include "WindowManager.h"
|
#include "WindowManager.h"
|
||||||
|
#include "Vulkan/VulkanGraphics.h"
|
||||||
|
|
||||||
Seele::WindowManager::WindowManager()
|
Seele::WindowManager::WindowManager()
|
||||||
{
|
{
|
||||||
|
graphics = new VulkanGraphics();
|
||||||
|
GraphicsInitializer initializer;
|
||||||
|
graphics->init(initializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Seele::WindowManager::~WindowManager()
|
Seele::WindowManager::~WindowManager()
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace Seele
|
|||||||
void endFrame();
|
void endFrame();
|
||||||
private:
|
private:
|
||||||
Array<PWindow> windows;
|
Array<PWindow> windows;
|
||||||
|
PGraphics graphics;
|
||||||
};
|
};
|
||||||
DEFINE_REF(WindowManager);
|
DEFINE_REF(WindowManager);
|
||||||
}
|
}
|
||||||
@@ -104,13 +104,13 @@ namespace Seele
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
RefPtr<F>& cast()
|
RefPtr<F> cast()
|
||||||
{
|
{
|
||||||
T* t = object->getHandle();
|
T* t = object->getHandle();
|
||||||
F* f = dynamic_cast<F*>(t);
|
F* f = dynamic_cast<F*>(t);
|
||||||
if (f == nullptr)
|
if (f == nullptr)
|
||||||
{
|
{
|
||||||
return RefPtr<F>();
|
return nullptr;
|
||||||
}
|
}
|
||||||
RefObject<F>* newObject = (RefObject<F>*)object;
|
RefObject<F>* newObject = (RefObject<F>*)object;
|
||||||
RefPtr<F> result(newObject);
|
RefPtr<F> result(newObject);
|
||||||
|
|||||||
Reference in New Issue
Block a user