From 7f6454d5506ddda8cbe8a3d2ea2102a72299d6e9 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 17 Aug 2018 17:24:50 +0200 Subject: [PATCH] Setup window title setter callback. --- profiler/src/main.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 5e30320e..3ed53000 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -1,3 +1,4 @@ +#include #include #include #include "imgui_impl_glfw_gl3.h" @@ -39,6 +40,15 @@ static void OpenWebpage( const char* url ) #endif } +static GLFWwindow* s_glfwWindow = nullptr; +static bool s_customTitle = false; +static void SetWindowTitleCallback( const char* title ) +{ + assert( s_glfwWindow ); + glfwSetWindowTitle( s_glfwWindow, title ); + s_customTitle = true; +} + int main( int argc, char** argv ) { std::unique_ptr view; @@ -67,6 +77,7 @@ int main( int argc, char** argv ) glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); #endif GLFWwindow* window = glfwCreateWindow(1650, 960, title, NULL, NULL); + s_glfwWindow = window; glfwMakeContextCurrent(window); glfwSwapInterval(1); // Enable vsync gl3wInit(); @@ -128,6 +139,12 @@ int main( int argc, char** argv ) if( !view ) { + if( s_customTitle ) + { + s_customTitle = false; + glfwSetWindowTitle( window, title ); + } + ImGui::Begin( "Tracy server", nullptr, ImGuiWindowFlags_AlwaysAutoResize ); ImGui::Text( "Tracy %i.%i.%i", tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch ); ImGui::SameLine(); @@ -150,7 +167,7 @@ int main( int argc, char** argv ) ImGui::InputText( "Address", addr, 1024 ); if( ImGui::Button( "Connect" ) && *addr && !loadThread.joinable() ) { - view = std::make_unique( addr, fixedWidth ); + view = std::make_unique( addr, fixedWidth, SetWindowTitleCallback ); } ImGui::Separator(); if( ImGui::Button( "Open saved trace" ) && !loadThread.joinable() ) @@ -167,7 +184,7 @@ int main( int argc, char** argv ) loadThread = std::thread( [&view, f, &badVer, fixedWidth] { try { - view = std::make_unique( *f, fixedWidth ); + view = std::make_unique( *f, fixedWidth, SetWindowTitleCallback ); } catch( const tracy::UnsupportedVersion& e ) {