Signed-off-by: falkTX <falktx@falktx.com>pull/272/head
@@ -91,8 +91,10 @@ public: | |||||
CairoImage& operator=(const CairoImage& image) noexcept; | CairoImage& operator=(const CairoImage& image) noexcept; | ||||
// FIXME this should not be needed | // FIXME this should not be needed | ||||
inline void loadFromMemory(const char* rawData, uint w, uint h, ImageFormat format) | |||||
inline void loadFromMemory(const char* rawData, uint w, uint h, ImageFormat format = kImageFormatBGRA) | |||||
{ loadFromMemory(rawData, Size<uint>(w, h), format); }; | { loadFromMemory(rawData, Size<uint>(w, h), format); }; | ||||
inline void draw(const GraphicsContext& context) | |||||
{ drawAt(context, Point<int>(0, 0)); }; | |||||
inline void drawAt(const GraphicsContext& context, int x, int y) | inline void drawAt(const GraphicsContext& context, int x, int y) | ||||
{ drawAt(context, Point<int>(x, y)); }; | { drawAt(context, Point<int>(x, y)); }; | ||||
@@ -17,7 +17,7 @@ | |||||
#ifndef DGL_VULKAN_HPP_INCLUDED | #ifndef DGL_VULKAN_HPP_INCLUDED | ||||
#define DGL_VULKAN_HPP_INCLUDED | #define DGL_VULKAN_HPP_INCLUDED | ||||
#include "Base.hpp" | |||||
#include "ImageBase.hpp" | |||||
#include <vulkan/vulkan_core.h> | #include <vulkan/vulkan_core.h> | ||||
@@ -34,6 +34,70 @@ struct VulkanGraphicsContext : GraphicsContext | |||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
/** | |||||
Vulkan Image class. | |||||
TODO ... | |||||
*/ | |||||
class VulkanImage : public ImageBase | |||||
{ | |||||
public: | |||||
/** | |||||
Constructor for a null Image. | |||||
*/ | |||||
VulkanImage(); | |||||
/** | |||||
Constructor using raw image data. | |||||
@note @a rawData must remain valid for the lifetime of this Image. | |||||
*/ | |||||
VulkanImage(const char* rawData, uint width, uint height, ImageFormat format); | |||||
/** | |||||
Constructor using raw image data. | |||||
@note @a rawData must remain valid for the lifetime of this Image. | |||||
*/ | |||||
VulkanImage(const char* rawData, const Size<uint>& size, ImageFormat format); | |||||
/** | |||||
Constructor using another image data. | |||||
*/ | |||||
VulkanImage(const VulkanImage& image); | |||||
/** | |||||
Destructor. | |||||
*/ | |||||
~VulkanImage() override; | |||||
/** | |||||
Load image data from memory. | |||||
@note @a rawData must remain valid for the lifetime of this Image. | |||||
*/ | |||||
void loadFromMemory(const char* rawData, | |||||
const Size<uint>& size, | |||||
ImageFormat format = kImageFormatBGRA) noexcept override; | |||||
/** | |||||
Draw this image at position @a pos using the graphics context @a context. | |||||
*/ | |||||
void drawAt(const GraphicsContext& context, const Point<int>& pos) override; | |||||
/** | |||||
TODO document this. | |||||
*/ | |||||
VulkanImage& operator=(const VulkanImage& image) noexcept; | |||||
// FIXME this should not be needed | |||||
inline void loadFromMemory(const char* rawData, uint w, uint h, ImageFormat format = kImageFormatBGRA) | |||||
{ loadFromMemory(rawData, Size<uint>(w, h), format); }; | |||||
inline void draw(const GraphicsContext& context) | |||||
{ drawAt(context, Point<int>(0, 0)); }; | |||||
inline void drawAt(const GraphicsContext& context, int x, int y) | |||||
{ drawAt(context, Point<int>(x, y)); }; | |||||
}; | |||||
// -------------------------------------------------------------------------------------------------------------------- | |||||
END_NAMESPACE_DGL | END_NAMESPACE_DGL | ||||
#endif | #endif |
@@ -164,6 +164,40 @@ template class Rectangle<uint>; | |||||
template class Rectangle<short>; | template class Rectangle<short>; | ||||
template class Rectangle<ushort>; | template class Rectangle<ushort>; | ||||
// ----------------------------------------------------------------------- | |||||
// VulkanImage | |||||
VulkanImage::VulkanImage() | |||||
: ImageBase() {} | |||||
VulkanImage::VulkanImage(const char* const rawData, const uint width, const uint height, const ImageFormat format) | |||||
: ImageBase(rawData, width, height, format) {} | |||||
VulkanImage::VulkanImage(const char* const rawData, const Size<uint>& size, const ImageFormat format) | |||||
: ImageBase(rawData, size, format) {} | |||||
VulkanImage::VulkanImage(const VulkanImage& image) | |||||
: ImageBase(image.rawData, image.size, image.format) {} | |||||
VulkanImage::~VulkanImage() {} | |||||
void VulkanImage::loadFromMemory(const char* const rdata, const Size<uint>& s, const ImageFormat fmt) noexcept | |||||
{ | |||||
ImageBase::loadFromMemory(rdata, s, fmt); | |||||
} | |||||
void VulkanImage::drawAt(const GraphicsContext&, const Point<int>&) | |||||
{ | |||||
} | |||||
VulkanImage& VulkanImage::operator=(const VulkanImage& image) noexcept | |||||
{ | |||||
rawData = image.rawData; | |||||
size = image.size; | |||||
format = image.format; | |||||
return *this; | |||||
} | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) | void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) | ||||
@@ -35,6 +35,10 @@ typedef DGL_NAMESPACE::CairoImage DemoImage; | |||||
#include "../dgl/OpenGL.hpp" | #include "../dgl/OpenGL.hpp" | ||||
typedef DGL_NAMESPACE::OpenGLImage DemoImage; | typedef DGL_NAMESPACE::OpenGLImage DemoImage; | ||||
#endif | #endif | ||||
#ifdef DGL_VULKAN | |||||
#include "../dgl/Vulkan.hpp" | |||||
typedef DGL_NAMESPACE::VulkanImage DemoImage; | |||||
#endif | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
@@ -245,6 +249,9 @@ public: | |||||
#ifdef DGL_OPENGL | #ifdef DGL_OPENGL | ||||
static constexpr const char* const kExampleWidgetName = "Demo - OpenGL"; | static constexpr const char* const kExampleWidgetName = "Demo - OpenGL"; | ||||
#endif | #endif | ||||
#ifdef DGL_VULKAN | |||||
static constexpr const char* const kExampleWidgetName = "Demo - Vulkan"; | |||||
#endif | |||||
DemoWindow(Application& app) | DemoWindow(Application& app) | ||||
: StandaloneWindow(app), | : StandaloneWindow(app), | ||||
@@ -27,6 +27,7 @@ TESTS += Demo.opengl | |||||
WTESTS += Window.opengl | WTESTS += Window.opengl | ||||
endif | endif | ||||
ifeq ($(HAVE_VULKAN),true) | ifeq ($(HAVE_VULKAN),true) | ||||
TESTS += Demo.vulkan | |||||
WTESTS = Window.vulkan | WTESTS = Window.vulkan | ||||
endif | endif | ||||