Only use imgui in debug builds
This commit is contained in:
parent
c92a62db3e
commit
91f66ef952
4 changed files with 41 additions and 12 deletions
|
@ -44,16 +44,25 @@ IMPORTED_LOCATION ${ASSIMP_IMPORTED_PATH})
|
|||
INTERFACE_INCLUDE_DIRECTORIES ${ASSIMP_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
add_executable(Graph
|
||||
set(GRAPH_SRC
|
||||
src/main.cpp
|
||||
src/renderer.cpp
|
||||
src/worldpass.cpp
|
||||
src/postpass.cpp
|
||||
src/dofpass.cpp
|
||||
src/imguipass.cpp
|
||||
src/skypass.cpp
|
||||
src/shadowpass.cpp
|
||||
src/config.cpp)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(GRAPH_SRC
|
||||
${GRAPH_SRC}
|
||||
src/imguipass.cpp)
|
||||
endif()
|
||||
|
||||
add_executable(Graph
|
||||
${GRAPH_SRC})
|
||||
|
||||
target_compile_options(Graph
|
||||
PUBLIC
|
||||
-fno-exceptions
|
||||
|
@ -64,8 +73,13 @@ target_link_libraries(Graph
|
|||
Vulkan::Vulkan
|
||||
assimp::assimp
|
||||
nlohmann::json
|
||||
stb::stb
|
||||
stb::stb)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
target_link_libraries(Graph
|
||||
PUBLIC
|
||||
imgui::imgui)
|
||||
endif()
|
||||
|
||||
target_include_directories(Graph
|
||||
PUBLIC
|
||||
|
|
|
@ -188,7 +188,9 @@ private:
|
|||
WorldPass* worldPass_ = nullptr;
|
||||
PostPass* postPass_ = nullptr;
|
||||
DoFPass* dofPass_ = nullptr;
|
||||
#ifdef DEBUG
|
||||
ImGuiPass* imguiPass_ = nullptr;
|
||||
#endif
|
||||
SkyPass* skyPass_ = nullptr;
|
||||
ShadowPass* shadowPass_ = nullptr;
|
||||
};
|
||||
|
|
|
@ -221,12 +221,14 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
SDL_SetWindowFullscreen(window, windowFullscreen == 1 ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
|
||||
#ifdef DEBUG
|
||||
ImGui::CreateContext();
|
||||
|
||||
auto& io = ImGui::GetIO();
|
||||
io.DisplaySize = ImVec2(windowWidth, windowHeight);
|
||||
|
||||
ImGui::StyleColorsDark();
|
||||
#endif
|
||||
|
||||
renderer = new Renderer(graphicsConfig);
|
||||
|
||||
|
@ -272,7 +274,9 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
if(event.type == SDL_WINDOWEVENT) {
|
||||
if(event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
#ifdef DEBUG
|
||||
io.DisplaySize = ImVec2(event.window.data1, event.window.data2);
|
||||
#endif
|
||||
|
||||
target = renderer->createSurfaceRenderTarget(surface, target);
|
||||
}
|
||||
|
@ -349,6 +353,7 @@ int main(int argc, char* argv[]) {
|
|||
const float deltaTime = currentTime - lastTime;
|
||||
lastTime = currentTime;
|
||||
|
||||
#ifdef DEBUG
|
||||
ImGui::NewFrame();
|
||||
|
||||
io.DeltaTime = deltaTime;
|
||||
|
@ -370,6 +375,8 @@ int main(int argc, char* argv[]) {
|
|||
ImGui::Text("dpack[2] = %f", (100 - camera.focusDistance) / 100.0f);
|
||||
|
||||
ImGui::Render();
|
||||
#endif
|
||||
|
||||
renderer->render(world, camera, target);
|
||||
|
||||
if(cinematicMode) {
|
||||
|
|
|
@ -30,7 +30,9 @@ Renderer::Renderer(GraphicsConfig config) : config_(config) {
|
|||
worldPass_ = new WorldPass(*this);
|
||||
postPass_ = new PostPass(*this);
|
||||
dofPass_ = new DoFPass(*this);
|
||||
#ifdef DEBUG
|
||||
imguiPass_ = new ImGuiPass(*this);
|
||||
#endif
|
||||
skyPass_ = new SkyPass(*this);
|
||||
}
|
||||
|
||||
|
@ -38,7 +40,9 @@ Renderer::~Renderer() {
|
|||
vkDeviceWaitIdle(device_);
|
||||
|
||||
delete skyPass_;
|
||||
#ifdef DEBUG
|
||||
delete imguiPass_;
|
||||
#endif
|
||||
delete dofPass_;
|
||||
delete postPass_;
|
||||
delete worldPass_;
|
||||
|
@ -127,7 +131,9 @@ void Renderer::render(World& world, Camera& camera, RenderTarget* target) {
|
|||
vkCmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
postPass_->render(commandBuffer, target);
|
||||
#ifdef DEBUG
|
||||
imguiPass_->render(commandBuffer, target);
|
||||
#endif
|
||||
|
||||
vkCmdEndRenderPass(commandBuffer);
|
||||
|
||||
|
@ -1155,39 +1161,39 @@ void Renderer::destroyMeshBuffers(Mesh* mesh) {
|
|||
}
|
||||
|
||||
void Renderer::createInstance() {
|
||||
std::vector<const char*> enabledLayers;
|
||||
#ifdef DEBUG
|
||||
uint32_t layerCount = 0;
|
||||
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
||||
|
||||
auto availableLayers = new VkLayerProperties[layerCount];
|
||||
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers);
|
||||
|
||||
std::vector<const char*> enabledLayers;
|
||||
#ifdef DEBUG
|
||||
for(uint32_t i = 0; i < layerCount; i++) {
|
||||
if(strcmp(availableLayers[i].layerName, "VK_LAYER_LUNARG_standard_validation") == 0)
|
||||
enabledLayers.push_back("VK_LAYER_LUNARG_standard_validation");
|
||||
}
|
||||
#endif
|
||||
|
||||
delete[] availableLayers;
|
||||
#endif
|
||||
|
||||
std::vector<const char*> enabledExtensions;
|
||||
#ifdef DEBUG
|
||||
uint32_t extensionCount = 0;
|
||||
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
|
||||
|
||||
auto availableExtensions = new VkExtensionProperties[extensionCount];
|
||||
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, availableExtensions);
|
||||
|
||||
std::vector<const char*> enabledExtensions;
|
||||
#ifdef DEBUG
|
||||
for(uint32_t i = 0; i < extensionCount; i++) {
|
||||
if(strcmp(availableExtensions[i].extensionName, "VK_EXT_debug_utils") == 0) {
|
||||
enabledExtensions.push_back("VK_EXT_debug_utils");
|
||||
enableDebug = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
delete[] availableExtensions;
|
||||
#endif
|
||||
|
||||
auto requiredExtensions = platform::getRequiredExtensions();
|
||||
enabledExtensions.insert(enabledExtensions.end(), requiredExtensions.begin(), requiredExtensions.end());
|
||||
|
|
Reference in a new issue