1919using namespace vkx ;
2020using namespace vkx ::ui;
2121
22- void UIOverlay::create (const UIOverlayCreateInfo& createInfo ) {
23- this -> createInfo = createInfo ;
22+ void UIOverlay::create (const UIOverlayCreateInfo& createInfo_ ) {
23+ createInfo = createInfo_ ;
2424#if defined(__ANDROID__)
2525 // Screen density
2626 if (vkx::android::screenDensity >= ACONFIGURATION_DENSITY_XXXHIGH) {
@@ -62,6 +62,7 @@ void UIOverlay::create(const UIOverlayCreateInfo& createInfo) {
6262
6363/* * Free up all Vulkan resources acquired by the UI overlay */
6464UIOverlay::~UIOverlay () {
65+ destroy ();
6566}
6667
6768void UIOverlay::destroy () {
@@ -79,6 +80,7 @@ void UIOverlay::destroy() {
7980 context.device .freeCommandBuffers (commandPool, cmdBuffers);
8081 context.device .destroyCommandPool (commandPool);
8182 context.device .destroyFence (fence);
83+ commandPool = nullptr ;
8284 }
8385}
8486
@@ -217,7 +219,7 @@ void UIOverlay::preparePipeline() {
217219
218220/* * Prepare a separate render pass for rendering the UI as an overlay */
219221void UIOverlay::prepareRenderPass () {
220- vk::AttachmentDescription attachments[ 2 ] = {} ;
222+ std::array< vk::AttachmentDescription, 2 > attachments ;
221223
222224 // Color attachment
223225 attachments[0 ].format = createInfo.colorformat ;
@@ -236,7 +238,7 @@ void UIOverlay::prepareRenderPass() {
236238
237239 vk::AttachmentReference colorReference{ 0 , vk::ImageLayout::eColorAttachmentOptimal };
238240 vk::AttachmentReference depthReference{ 1 , vk::ImageLayout::eDepthStencilAttachmentOptimal };
239- vk::SubpassDependency subpassDependencies[ 2 ] ;
241+ std::array< vk::SubpassDependency, 2 > subpassDependencies ;
240242
241243 // Transition from final to initial (VK_SUBPASS_EXTERNAL refers to all commmands executed outside of the actual renderpass)
242244 subpassDependencies[0 ].srcSubpass = VK_SUBPASS_EXTERNAL;
@@ -263,11 +265,11 @@ void UIOverlay::prepareRenderPass() {
263265
264266 vk::RenderPassCreateInfo renderPassInfo;
265267 renderPassInfo.attachmentCount = 2 ;
266- renderPassInfo.pAttachments = attachments;
268+ renderPassInfo.pAttachments = attachments. data () ;
267269 renderPassInfo.subpassCount = 1 ;
268270 renderPassInfo.pSubpasses = &subpassDescription;
269271 renderPassInfo.dependencyCount = 2 ;
270- renderPassInfo.pDependencies = subpassDependencies;
272+ renderPassInfo.pDependencies = subpassDependencies. data () ;
271273
272274 renderPass = context.device .createRenderPass (renderPassInfo);
273275}
@@ -292,7 +294,7 @@ void UIOverlay::updateCommandBuffers() {
292294
293295 if (cmdBuffers.size ()) {
294296 context.trashAll <vk::CommandBuffer>(cmdBuffers,
295- [& ](const std::vector<vk::CommandBuffer>& buffers) { context.device .freeCommandBuffers (commandPool, buffers); });
297+ [this ](const std::vector<vk::CommandBuffer>& buffers) { context.device .freeCommandBuffers (commandPool, buffers); });
296298 cmdBuffers.clear ();
297299 }
298300
@@ -404,8 +406,8 @@ void UIOverlay::update() {
404406 }
405407
406408 // Upload data
407- ImDrawVert* vtxDst = (ImDrawVert*)vertexBuffer.mapped ;
408- ImDrawIdx* idxDst = (ImDrawIdx*)indexBuffer.mapped ;
409+ auto vtxDst = (ImDrawVert*)vertexBuffer.mapped ;
410+ auto idxDst = (ImDrawIdx*)indexBuffer.mapped ;
409411
410412 for (int n = 0 ; n < imDrawData->CmdListsCount ; n++) {
411413 const ImDrawList* cmd_list = imDrawData->CmdLists [n];
@@ -465,8 +467,8 @@ bool UIOverlay::checkBox(const char* caption, int32_t* value) const {
465467 return res;
466468}
467469
468- bool UIOverlay::inputFloat (const char * caption, float * value, float step, uint32_t precision ) const {
469- return ImGui::InputFloat (caption, value, step, step * 10 .0f , precision );
470+ bool UIOverlay::inputFloat (const char * caption, float * value, float step, const char * format ) const {
471+ return ImGui::InputFloat (caption, value, step, step * 10 .0f , format );
470472}
471473
472474bool UIOverlay::sliderFloat (const char * caption, float * value, float min, float max) const {
@@ -486,7 +488,7 @@ bool UIOverlay::comboBox(const char* caption, int32_t* itemindex, const std::vec
486488 for (size_t i = 0 ; i < items.size (); i++) {
487489 charitems.push_back (items[i].c_str ());
488490 }
489- uint32_t itemCount = static_cast <uint32_t >(charitems.size ());
491+ auto itemCount = static_cast <uint32_t >(charitems.size ());
490492 return ImGui::Combo (caption, itemindex, &charitems[0 ], itemCount, itemCount);
491493}
492494
0 commit comments