Changeset ea2b4dc in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Feb 14, 2021, 4:24:08 AM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
880cfc2
Parents:
1cb64e6
git-author:
Dmitry Portnoy <dportnoy@…> (02/14/21 04:23:03)
git-committer:
Dmitry Portnoy <dportnoy@…> (02/14/21 04:24:08)
Message:

In VulkanGame, generate the IMGUI draw data outside of renderFrame() and
pass it in, instead ofgenerating it inside the function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r1cb64e6 rea2b4dc  
    88
    99#include "IMGUI/imgui_impl_sdl.h"
    10 #include "IMGUI/imgui_impl_vulkan.h"
    1110
    1211#include "logger.hpp"
     
    945944         sdlOverlayImage, graphicsQueue);
    946945
    947       renderFrame();
     946      updateScene();
     947
     948      ImGui_ImplVulkan_NewFrame();
     949      ImGui_ImplSDL2_NewFrame(this->window);
     950      ImGui::NewFrame();
     951
     952      {
     953         ImGui::SetNextWindowSize(ImVec2(250, 35), ImGuiCond_Once);
     954         ImGui::SetNextWindowPos(ImVec2(380, 10), ImGuiCond_Once);
     955         ImGui::Begin("WndMenubar", NULL,
     956            ImGuiWindowFlags_NoTitleBar |
     957            ImGuiWindowFlags_NoResize |
     958            ImGuiWindowFlags_NoMove);
     959         ImGui::InvisibleButton("", ImVec2(155, 18));
     960         ImGui::SameLine();
     961         if (ImGui::Button("Main Menu")) {
     962            cout << "Clicked on the main button" << endl;
     963            //events.push(Event::GO_TO_MAIN_MENU);
     964         }
     965         ImGui::End();
     966      }
     967
     968      ImGui::Render();
     969
     970      renderFrame(ImGui::GetDrawData());
    948971      presentFrame();
    949972   }
     
    16871710}
    16881711
    1689 void VulkanGame::renderFrame() {
     1712void VulkanGame::renderFrame(ImDrawData* draw_data) {
    16901713   VkResult result = vkAcquireNextImageKHR(device, swapChain, numeric_limits<uint64_t>::max(),
    16911714      imageAcquiredSemaphores[currentFrame], VK_NULL_HANDLE, &imageIndex);
     
    17041727      throw runtime_error("failed to reset fence!");
    17051728   }
    1706 
    1707    updateScene();
    17081729
    17091730   VKUTIL_CHECK_RESULT(vkResetCommandPool(device, commandPools[imageIndex], 0),
     
    17371758   currentScreen->createRenderCommands(commandBuffers[imageIndex], imageIndex);
    17381759
    1739    /**********************************************************/
    1740 
    1741    ImGui_ImplVulkan_NewFrame();
    1742    ImGui_ImplSDL2_NewFrame(this->window);
    1743    ImGui::NewFrame();
    1744 
    1745    {
    1746       ImGui::SetNextWindowSize(ImVec2(250, 35), ImGuiCond_Once);
    1747       ImGui::SetNextWindowPos(ImVec2(380, 10), ImGuiCond_Once);
    1748       ImGui::Begin("WndMenubar", NULL,
    1749          ImGuiWindowFlags_NoTitleBar |
    1750          ImGuiWindowFlags_NoResize |
    1751          ImGuiWindowFlags_NoMove);
    1752       ImGui::InvisibleButton("", ImVec2(155, 18));
    1753       ImGui::SameLine();
    1754       if (ImGui::Button("Main Menu")) {
    1755          cout << "Clicked on the main button" << endl;
    1756          //events.push(Event::GO_TO_MAIN_MENU);
    1757       }
    1758       ImGui::End();
    1759    }
    1760 
    1761    ImGui::Render();
    1762    ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), commandBuffers[imageIndex]);
    1763 
    1764    /**********************************************************/
     1760   ImGui_ImplVulkan_RenderDrawData(draw_data, commandBuffers[imageIndex]);
    17651761
    17661762   vkCmdEndRenderPass(commandBuffers[imageIndex]);
Note: See TracChangeset for help on using the changeset viewer.