diff --git a/base/VulkanUIOverlay.cpp b/base/VulkanUIOverlay.cpp index 07c729b3..6ab932cf 100644 --- a/base/VulkanUIOverlay.cpp +++ b/base/VulkanUIOverlay.cpp @@ -552,4 +552,40 @@ namespace vks vks::initializers::commandBufferAllocateInfo(commandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY, static_cast(cmdBuffers.size())); VK_CHECK_RESULT(vkAllocateCommandBuffers(device->logicalDevice, &cmdBufAllocateInfo, cmdBuffers.data())); } + + bool UIOverlay::header(const char *caption) + { + return ImGui::CollapsingHeader(caption, ImGuiTreeNodeFlags_DefaultOpen); + } + + bool UIOverlay::checkBox(const char *caption, bool *value) + { + return ImGui::Checkbox(caption, value); + } + + bool UIOverlay::inputFloat(const char *caption, float *value, float step, uint32_t precision) + { + return ImGui::InputFloat(caption, value, step, step * 10.0f, precision); + } + + bool UIOverlay::comboBox(const char *caption, int32_t *itemindex, std::vector items) + { + if (items.empty()) { + return false; + } + std::vector charitems; + charitems.reserve(items.size()); + for (size_t i = 0; i < items.size(); i++) { + charitems.push_back(items[i].c_str()); + } + return ImGui::Combo(caption, itemindex, &charitems[0], static_cast(charitems.size()), 4); + } + + void UIOverlay::text(const char *formatstr, ...) + { + va_list args; + va_start(args, formatstr); + ImGui::TextV(formatstr, args); + va_end(args); + } } \ No newline at end of file diff --git a/base/VulkanUIOverlay.h b/base/VulkanUIOverlay.h index 0049915e..0338756e 100644 --- a/base/VulkanUIOverlay.h +++ b/base/VulkanUIOverlay.h @@ -86,5 +86,11 @@ namespace vks void update(); void submit(VkQueue queue, uint32_t bufferindex, VkSubmitInfo submitInfo); + + bool header(const char* caption); + bool checkBox(const char* caption, bool* value); + bool inputFloat(const char* caption, float* value, float step, uint32_t precision); + bool comboBox(const char* caption, int32_t* itemindex, std::vector items); + void text(const char* formatstr, ...); }; } \ No newline at end of file