vsgImGui 0.5.0
VulkanSceneGraph, ImGui and ImPlot integration library
Loading...
Searching...
No Matches
RenderImGui.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2021 Don Burns, Roland Hill and Robert Osfield.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of
8this software and associated documentation files (the "Software"), to deal in
9the Software without restriction, including without limitation the rights to
10use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11the Software, and to permit persons to whom the Software is furnished to do so,
12subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24</editor-fold> */
25
26#include <functional>
27
28#include <vsg/app/Window.h>
29#include <vsg/commands/ClearAttachments.h>
30#include <vsg/nodes/Group.h>
31#include <vsg/vk/DescriptorPool.h>
32
33#include <vsgImGui/Export.h>
34#include <vsgImGui/imgui.h>
35
36namespace vsgImGui
37{
38
39 class VSGIMGUI_DECLSPEC RenderImGui : public vsg::Inherit<vsg::Group, RenderImGui>
40 {
41 public:
42 RenderImGui(const vsg::ref_ptr<vsg::Window>& window, bool useClearAttachments = false);
43
44 RenderImGui(vsg::ref_ptr<vsg::Device> device, uint32_t queueFamily,
45 vsg::ref_ptr<vsg::RenderPass> renderPass,
46 uint32_t minImageCount, uint32_t imageCount,
47 VkExtent2D imageSize, bool useClearAttachments = false);
48
49 template<typename... Args>
50 RenderImGui(const vsg::ref_ptr<vsg::Window>& window, Args&&... args) :
51 RenderImGui(window, false)
52 {
53 (add(args), ...);
54 }
55
56 template<typename... Args>
57 RenderImGui(const vsg::ref_ptr<vsg::Window>& window, Args&&... args, bool useClearAttachments) :
58 RenderImGui(window, useClearAttachments)
59 {
60 (add(args), ...);
61 }
62
64 using LegacyFunction = std::function<bool()>;
65
67 void add(const LegacyFunction& legacyFunc);
68
70 void add(vsg::ref_ptr<vsg::Node> child) { addChild(child); }
71
72 void accept(vsg::RecordTraversal& rt) const override;
73
74 private:
75 virtual ~RenderImGui();
76
77 vsg::ref_ptr<vsg::Device> _device;
78 uint32_t _queueFamily;
79 vsg::ref_ptr<vsg::Queue> _queue;
80 vsg::ref_ptr<vsg::DescriptorPool> _descriptorPool;
81
82 vsg::ref_ptr<vsg::ClearAttachments> _clearAttachments;
83
84 void _init(const vsg::ref_ptr<vsg::Window>& window, bool useClearAttachments);
85 void _init(vsg::ref_ptr<vsg::Device> device, uint32_t queueFamily,
86 vsg::ref_ptr<vsg::RenderPass> renderPass,
87 uint32_t minImageCount, uint32_t imageCount,
88 VkExtent2D imageSize, bool useClearAttachments);
89 void _uploadFonts();
90 };
91
92} // namespace vsgImGui
93
94EVSG_type_name(vsgImGui::RenderImGui);
Definition RenderImGui.h:40
void add(const LegacyFunction &legacyFunc)
add a GUI rendering component that provides the ImGui calls to render the required GUI elements.
void add(vsg::ref_ptr< vsg::Node > child)
add a child, equivalent to Group::addChild(..) but adds compatibility with the RenderImGui constructo...
Definition RenderImGui.h:70
std::function< bool()> LegacyFunction
std::function signature used for older vsgImGui versions
Definition RenderImGui.h:64