TGUI 1.14-dev
Loading...
Searching...
No Matches
SDL-Vulkan.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2026 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef TGUI_BACKEND_SDL_VULKAN_INCLUDE_HPP
26#define TGUI_BACKEND_SDL_VULKAN_INCLUDE_HPP
27
28#include <TGUI/Config.hpp>
29#if !TGUI_HAS_BACKEND_SDL_VULKAN
30 #error "TGUI wasn't build with the SDL_VULKAN backend"
31#endif
32
33#include <TGUI/Backend/Font/FreeType/BackendFontFreeType.hpp>
34#include <TGUI/Backend/Renderer/Vulkan/BackendRendererVulkan.hpp>
35#include <TGUI/Backend/Window/SDL/BackendSDL.hpp>
36
38
39namespace tgui
40{
41 class SwapchainVulkan;
42
43 inline namespace SDL_VULKAN
44 {
51 class TGUI_API Gui : public BackendGuiSDL
52 {
53 public:
59 Gui();
60
67 Gui(SDL_Window* window, const VulkanContext& vulkanContext);
68
72 ~Gui() override;
73
82 void setWindow(SDL_Window* window, const VulkanContext& vulkanContext);
83
103 void setRenderPass(VkRenderPass renderPass,
104 VkFormat colorFormat,
105 std::uint32_t maxFramesInFlight,
106 std::uint32_t subpass = 0,
107 VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT);
108
130 void setDynamicRenderingFormats(VkFormat colorFormat,
131 std::uint32_t maxFramesInFlight,
132 VkFormat depthFormat = VK_FORMAT_UNDEFINED,
133 VkFormat stencilFormat = VK_FORMAT_UNDEFINED,
134 VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT);
135
139 TGUI_DEPRECATED("This backend requires a command buffer, use draw(VkCommandBuffer) instead") void draw() override
140 {
141 TGUI_ASSERT(false, "The SDL_VULKAN backend requires that you pass a VkCommandBuffer to the draw function");
142 throw Exception("The SDL_VULKAN backend requires that you pass a VkCommandBuffer to the draw function");
143 }
144
157 void draw(VkCommandBuffer cmdBuffer);
158
170 void mainLoop(Color clearColor = {240, 240, 240}) override;
171
173
174 protected:
178 void renderFrame(Color clearColor) override;
179
183 void presentScreen() override;
184
189
190 protected:
191 std::unique_ptr<SwapchainVulkan> m_swapchain; // Only exists while mainLoop is running
192 };
193 } // namespace SDL_VULKAN
194} // namespace tgui
195
196#endif // TGUI_BACKEND_SDL_VULKAN_INCLUDE_HPP
BackendGuiSDL()=default
Default constructor.
Wrapper for colors.
Definition Color.hpp:63
Definition Exception.hpp:46
~Gui() override
Destructor.
void createSwapchain()
Creates a new surface and swapchain for the window, replacing the existing ones.
void presentScreen() override
Not used by this backend.
Gui()
Default constructor.
void mainLoop(Color clearColor={240, 240, 240}) override
Give the gui control over the main loop.
void setRenderPass(VkRenderPass renderPass, VkFormat colorFormat, std::uint32_t maxFramesInFlight, std::uint32_t subpass=0, VkSampleCountFlagBits samples=VK_SAMPLE_COUNT_1_BIT)
Informs the gui about the render pass in which draw(cmdBuffer) will be called.
void draw(VkCommandBuffer cmdBuffer)
Draws all the widgets that were added to the gui.
void setDynamicRenderingFormats(VkFormat colorFormat, std::uint32_t maxFramesInFlight, VkFormat depthFormat=VK_FORMAT_UNDEFINED, VkFormat stencilFormat=VK_FORMAT_UNDEFINED, VkSampleCountFlagBits samples=VK_SAMPLE_COUNT_1_BIT)
Informs the gui that draw(cmdBuffer) will be called while using dynamic rendering (vkCmdBeginRenderin...
void setWindow(SDL_Window *window, const VulkanContext &vulkanContext)
Sets the window and Vulkan objects with which the gui should be drawn.
void renderFrame(Color clearColor) override
Clears the window, draws the gui and then presents the frame.
Gui(SDL_Window *window, const VulkanContext &vulkanContext)
Constructor that immediately sets the window and Vulkan objects with which the gui should be drawn.
void draw() override
This function is not used by this backend, use draw(VkCommandBuffer) instead.
Definition SDL-Vulkan.hpp:139
Definition SwapchainVulkan.hpp:51
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
Vulkan objects that TGUI needs to render.
Definition BackendRendererVulkan.hpp:50