diff --git a/lib/graphics_engine/include/ge_vulkan_driver.hpp b/lib/graphics_engine/include/ge_vulkan_driver.hpp index 64f35a846..48f3f3b73 100644 --- a/lib/graphics_engine/include/ge_vulkan_driver.hpp +++ b/lib/graphics_engine/include/ge_vulkan_driver.hpp @@ -144,7 +144,11 @@ namespace GE //!Draws an 2d rectangle with a gradient. virtual void draw2DRectangle(const core::rect& pos, SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, - const core::rect* clip) {} + const core::rect* clip) + { + SColor color[4] = { colorLeftUp, colorLeftDown, colorRightDown, colorRightUp }; + draw2DImage(m_white_texture, pos, core::recti(0, 0, 2, 2), clip, color, true); + } //! Draws a 2d line. virtual void draw2DLine(const core::position2d& start, @@ -311,6 +315,9 @@ namespace GE constexpr static unsigned getMaxFrameInFlight() { return 2; } video::SColor getClearColor() const { return m_clear_color; } const core::rect& getCurrentClip() const { return m_clip; } + video::ITexture* getWhiteTexture() const { return m_white_texture; } + video::ITexture* getTransparentTexture() const + { return m_transparent_texture; } private: struct SwapChainSupportDetails { @@ -426,6 +433,9 @@ namespace GE video::SColor m_clear_color; core::rect m_clip; + video::ITexture* m_white_texture; + video::ITexture* m_transparent_texture; + void createInstance(SDL_Window* window); void findPhysicalDevice(); bool checkDeviceExtensions(VkPhysicalDevice device); @@ -442,6 +452,7 @@ namespace GE void createSamplers(); void createRenderPass(); void createFramebuffers(); + void createUnicolorTextures(); std::string getVulkanVersionString() const; std::string getDriverVersionString() const; }; diff --git a/lib/graphics_engine/src/ge_vulkan_driver.cpp b/lib/graphics_engine/src/ge_vulkan_driver.cpp index 6ef184a83..ce18df572 100644 --- a/lib/graphics_engine/src/ge_vulkan_driver.cpp +++ b/lib/graphics_engine/src/ge_vulkan_driver.cpp @@ -459,6 +459,7 @@ GEVulkanDriver::GEVulkanDriver(const SIrrlichtCreationParameters& params, m_current_frame = 0; m_image_index = 0; m_clear_color = video::SColor(0); + m_white_texture = NULL; createInstance(window); @@ -507,6 +508,7 @@ GEVulkanDriver::GEVulkanDriver(const SIrrlichtCreationParameters& params, // For GEVulkanDynamicBuffer GE::setVideoDriver(this); GEVulkan2dRenderer::init(this); + createUnicolorTextures(); os::Printer::log("Vulkan version", getVulkanVersionString().c_str()); os::Printer::log("Vulkan vendor", getVendorInfo().c_str()); os::Printer::log("Vulkan renderer", m_properties.deviceName); @@ -524,12 +526,40 @@ GEVulkanDriver::~GEVulkanDriver() // ---------------------------------------------------------------------------- void GEVulkanDriver::destroyVulkan() { + if (m_white_texture) + { + m_white_texture->drop(); + m_white_texture = NULL; + } + if (m_transparent_texture) + { + m_transparent_texture->drop(); + m_transparent_texture = NULL; + } + GEVulkan2dRenderer::destroy(); GEVulkanShaderManager::destroy(); delete m_vk.get(); m_vk.release(); } // destroyVulkan +// ---------------------------------------------------------------------------- +void GEVulkanDriver::createUnicolorTextures() +{ + constexpr unsigned size = 2; + std::array data; + data.fill(255); + video::IImage* img = createImageFromData(video::ECF_A8R8G8B8, + core::dimension2d(size, size), data.data(), + /*ownForeignMemory*/true, /*deleteMemory*/false); + m_white_texture = new GEVulkanTexture(img, "unicolor_white"); + data.fill(0); + img = createImageFromData(video::ECF_A8R8G8B8, + core::dimension2d(size, size), data.data(), + /*ownForeignMemory*/true, /*deleteMemory*/false); + m_transparent_texture = new GEVulkanTexture(img, "unicolor_transparent"); +} // createUnicolorTextures + // ---------------------------------------------------------------------------- void GEVulkanDriver::createInstance(SDL_Window* window) {