PeriDyno 1.0.0
Loading...
Searching...
No Matches
VulkanUIOverlay.h
Go to the documentation of this file.
1/*
2* UI overlay class using ImGui
3*
4* Copyright (C) 2017 by Sascha Willems - www.saschawillems.de
5*
6* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
7*/
8
9#pragma once
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14#include <assert.h>
15#include <vector>
16#include <sstream>
17#include <iomanip>
18
19#include <vulkan/vulkan.h>
20#include "VulkanTools.h"
21#include "VulkanDebug.h"
22#include "VulkanBuffer.h"
23#include "VkContext.h"
24
25#include "imgui/imgui.h"
26
27#include <glm/glm.hpp>
28
29#if defined(__ANDROID__)
30#include "VulkanAndroid.h"
31#endif
32
33namespace vks
34{
35 class UIOverlay
36 {
37 protected:
39
40 public:
41 VkSampleCountFlagBits rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
42 uint32_t subpass = 0;
43
44 std::shared_ptr<vks::Buffer> vertexBuffer;
45 std::shared_ptr<vks::Buffer> indexBuffer;
46 int32_t vertexCount = 0;
47 int32_t indexCount = 0;
48
49 std::vector<VkPipelineShaderStageCreateInfo> shaders;
50
51 VkDescriptorPool descriptorPool;
52 VkDescriptorSetLayout descriptorSetLayout;
53 VkDescriptorSet descriptorSet;
54 VkPipelineLayout pipelineLayout;
55 VkPipeline pipeline;
56
57 VkDeviceMemory fontMemory = VK_NULL_HANDLE;
58 VkImage fontImage = VK_NULL_HANDLE;
59 VkImageView fontView = VK_NULL_HANDLE;
60 VkSampler sampler;
61
63 glm::vec2 scale;
64 glm::vec2 translate;
66
67 bool visible = true;
68 bool updated = false;
69 float scale = 1.0f;
70
71 UIOverlay();
72 ~UIOverlay();
73
74 void preparePipeline(const VkPipelineCache pipelineCache, const VkRenderPass renderPass);
75 void prepareResources();
76
77 bool update();
78 void draw(const VkCommandBuffer commandBuffer);
79 void resize(uint32_t width, uint32_t height);
80
81 void freeResources();
82
83 bool header(const char* caption);
84 bool checkBox(const char* caption, bool* value);
85 bool checkBox(const char* caption, int32_t* value);
86 bool inputFloat(const char* caption, float* value, float step, uint32_t precision);
87 bool sliderFloat(const char* caption, float* value, float min, float max);
88 bool sliderInt(const char* caption, int32_t* value, int32_t min, int32_t max);
89 bool comboBox(const char* caption, int32_t* itemindex, std::vector<std::string> items);
90 bool button(const char* caption);
91 void text(const char* formatstr, ...);
92 };
93}
VkImageView fontView
bool inputFloat(const char *caption, float *value, float step, uint32_t precision)
VkDescriptorPool descriptorPool
std::shared_ptr< vks::Buffer > vertexBuffer
bool sliderFloat(const char *caption, float *value, float min, float max)
bool comboBox(const char *caption, int32_t *itemindex, std::vector< std::string > items)
VkDeviceMemory fontMemory
bool sliderInt(const char *caption, int32_t *value, int32_t min, int32_t max)
bool checkBox(const char *caption, bool *value)
void draw(const VkCommandBuffer commandBuffer)
struct vks::UIOverlay::PushConstBlock pushConstBlock
dyno::VkContext * ctx
bool button(const char *caption)
void resize(uint32_t width, uint32_t height)
void text(const char *formatstr,...)
VkDescriptorSetLayout descriptorSetLayout
bool header(const char *caption)
void preparePipeline(const VkPipelineCache pipelineCache, const VkRenderPass renderPass)
VkPipelineLayout pipelineLayout
VkPipeline pipeline
VkSampleCountFlagBits rasterizationSamples
VkDescriptorSet descriptorSet
std::shared_ptr< vks::Buffer > indexBuffer
std::vector< VkPipelineShaderStageCreateInfo > shaders
#define max(x, y)
Definition svd3_cuda.h:41