TGUI 1.14-dev
Loading...
Searching...
No Matches
GLFW-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_GLFW_VULKAN_INCLUDE_HPP
26#define TGUI_BACKEND_GLFW_VULKAN_INCLUDE_HPP
27
28#include <TGUI/Config.hpp>
29#if !TGUI_HAS_BACKEND_GLFW_VULKAN
30 #error "TGUI wasn't build with the GLFW_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/GLFW/BackendGLFW.hpp>
36
38
39using GLFWwindow = struct GLFWwindow;
40
41namespace tgui
42{
43 class SwapchainVulkan;
44
45 inline namespace GLFW_VULKAN
46 {
53 class TGUI_API Gui : public BackendGuiGLFW
54 {
55 public:
61 Gui();
62
69 Gui(GLFWwindow* window, const VulkanContext& vulkanContext);
70
74 ~Gui() override;
75
84 void setWindow(GLFWwindow* window, const VulkanContext& vulkanContext);
85
105 void setRenderPass(VkRenderPass renderPass,
106 VkFormat colorFormat,
107 std::uint32_t maxFramesInFlight,
108 std::uint32_t subpass = 0,
109 VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT);
110
132 void setDynamicRenderingFormats(VkFormat colorFormat,
133 std::uint32_t maxFramesInFlight,
134 VkFormat depthFormat = VK_FORMAT_UNDEFINED,
135 VkFormat stencilFormat = VK_FORMAT_UNDEFINED,
136 VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT);
137
141 TGUI_DEPRECATED("This backend requires a command buffer, use draw(VkCommandBuffer) instead") void draw() override
142 {
143 TGUI_ASSERT(false, "The GLFW_VULKAN backend requires that you pass a VkCommandBuffer to the draw function");
144 throw Exception("The GLFW_VULKAN backend requires that you pass a VkCommandBuffer to the draw function");
145 }
146
159 void draw(VkCommandBuffer cmdBuffer);
160
172 void mainLoop(Color clearColor = {240, 240, 240}) override;
173
175
176 protected:
180 void renderFrame(Color clearColor) override;
181
186
187 protected:
188 std::unique_ptr<SwapchainVulkan> m_swapchain; // Only exists while mainLoop is running
189 };
190 } // namespace GLFW_VULKAN
191} // namespace tgui
192
193#endif // TGUI_BACKEND_GLFW_VULKAN_INCLUDE_HPP
BackendGuiGLFW()
Default constructor.
Wrapper for colors.
Definition Color.hpp:63
Definition Exception.hpp:46
void createSwapchain()
Creates a new surface and swapchain for the window, replacing the existing ones.
void renderFrame(Color clearColor) override
Clears the window, draws the gui and then presents the frame.
Gui(GLFWwindow *window, const VulkanContext &vulkanContext)
Constructor that immediately sets the window and Vulkan objects with which the gui should be drawn.
~Gui() override
Destructor.
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 setWindow(GLFWwindow *window, const VulkanContext &vulkanContext)
Sets the window and Vulkan objects with which the gui should be drawn.
void draw(VkCommandBuffer cmdBuffer)
Draws all the widgets that were added to the gui.
Gui()
Default constructor.
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 mainLoop(Color clearColor={240, 240, 240}) override
Give the gui control over the main loop.
void draw() override
This function is not used by this backend, use draw(VkCommandBuffer) instead.
Definition GLFW-Vulkan.hpp:141
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