diff --git a/neo/imgui/BFGimguiImpl.cpp b/neo/imgui/BFGimguiImpl.cpp index 6a93476c..13c11bb6 100644 --- a/neo/imgui/BFGimguiImpl.cpp +++ b/neo/imgui/BFGimguiImpl.cpp @@ -17,6 +17,8 @@ #include "renderer/RenderBackend.h" +idCVar imgui_showDemoWindow( "imgui_showDemoWindow", "0", CVAR_GUI | CVAR_BOOL, "show big ImGui demo window" ); + // our custom ImGui functions from BFGimgui.h // like DragFloat3(), but with "X: ", "Y: " or "Z: " prepended to each display_format, for vectors @@ -180,10 +182,13 @@ void FillCharKeys( int* keyMap ) // Sys_GetClipboardData() expects that you Mem_Free() its returned data // ImGui can't do that, of course, so copy it into a static buffer here, // Mem_Free() and return the copy -const char* GetClipboardWrapper() +const char* GetClipboardText( void* ) { char* txt = Sys_GetClipboardData(); - if( txt == NULL ) return NULL; + if( txt == NULL ) + { + return NULL; + } static idStr clipboardBuf; clipboardBuf = txt; @@ -193,10 +198,15 @@ const char* GetClipboardWrapper() return clipboardBuf.c_str(); } +void SetClipboardText( void*, const char* text ) +{ + Sys_SetClipboardData( text ); +} + bool ShowWindows() { - return ImGuiTools::AreEditorsActive(); + return ( ImGuiTools::AreEditorsActive() || imgui_showDemoWindow.GetBool() ); } bool UseInput() @@ -213,6 +223,10 @@ bool Init( int windowWidth, int windowHeight ) Destroy(); } + IMGUI_CHECKVERSION(); + + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. io.KeyMap[ImGuiKey_Tab] = K_TAB; @@ -236,15 +250,22 @@ bool Init( int windowWidth, int windowHeight ) io.DisplaySize = g_DisplaySize; io.RenderDrawListsFn = idRenderBackend::ImGui_RenderDrawLists; - io.SetClipboardTextFn = Sys_SetClipboardData; - io.GetClipboardTextFn = GetClipboardWrapper; + + // RB: FIXME double check + io.SetClipboardTextFn = SetClipboardText; + io.GetClipboardTextFn = GetClipboardText; + io.ClipboardUserData = NULL; // make it a bit prettier with rounded edges ImGuiStyle& style = ImGui::GetStyle(); - style.ChildWindowRounding = 9.0f; - style.FrameRounding = 4.0f; - style.ScrollbarRounding = 4.0f; - style.GrabRounding = 4.0f; + //style.ChildWindowRounding = 9.0f; + //style.FrameRounding = 4.0f; + //style.ScrollbarRounding = 4.0f; + //style.GrabRounding = 4.0f; + + // Setup style + ImGui::StyleColorsDark(); + //ImGui::StyleColorsClassic(); g_IsInit = true; @@ -321,13 +342,6 @@ void NewFrame() { if( IsInitialized() && ShowWindows() ) { - /* - if( !g_FontTexture ) - { - CreateDeviceObjects(); - } - */ - ImGuiIO& io = ImGui::GetIO(); // Setup display size (every frame to accommodate for window resizing) @@ -361,6 +375,11 @@ void NewFrame() // Start the frame ImGui::NewFrame(); g_haveNewFrame = true; + + if( imgui_showDemoWindow.GetBool() && !ImGuiTools::ReleaseMouseForTools() ) + { + ImGuiTools::impl::SetReleaseToolMouse( true ); + } } } @@ -377,6 +396,11 @@ void Render() ImGuiTools::DrawToolWindows(); + if( imgui_showDemoWindow.GetBool() ) + { + ImGui::ShowDemoWindow(); + } + ImGui::Render(); g_haveNewFrame = false; } @@ -386,7 +410,7 @@ void Destroy() { if( IsInitialized() ) { - ImGui::Shutdown(); + ImGui::DestroyContext(); g_IsInit = false; } } diff --git a/neo/renderer/Image_intrinsic.cpp b/neo/renderer/Image_intrinsic.cpp index e569b716..54b26275 100644 --- a/neo/renderer/Image_intrinsic.cpp +++ b/neo/renderer/Image_intrinsic.cpp @@ -836,8 +836,8 @@ static void R_CreateImGuiFontImage( idImage* image ) io.Fonts->TexID = ( void* )( intptr_t )image->GetImGuiTextureID(); // Cleanup (don't clear the input data if you want to append new fonts later) - io.Fonts->ClearInputData(); - io.Fonts->ClearTexData(); + //io.Fonts->ClearInputData(); + //io.Fonts->ClearTexData(); } // RB end diff --git a/neo/renderer/OpenGL/RenderBackend_GL.cpp b/neo/renderer/OpenGL/RenderBackend_GL.cpp index 51765d68..751e373d 100644 --- a/neo/renderer/OpenGL/RenderBackend_GL.cpp +++ b/neo/renderer/OpenGL/RenderBackend_GL.cpp @@ -2217,7 +2217,7 @@ void idRenderBackend::ImGui_Shutdown() glDeleteProgram( g_ShaderHandle ); g_ShaderHandle = 0; - ImGui::GetIO().Fonts->TexID = 0; + //ImGui::GetIO().Fonts->TexID = 0; } // This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) diff --git a/neo/tools/imgui/lighteditor/LightEditor.cpp b/neo/tools/imgui/lighteditor/LightEditor.cpp index 3df1a70e..d77f4ab6 100644 --- a/neo/tools/imgui/lighteditor/LightEditor.cpp +++ b/neo/tools/imgui/lighteditor/LightEditor.cpp @@ -471,7 +471,7 @@ static float* vecToArr( idVec3& v ) void LightEditor::DrawWindow() { bool showWindow = showIt; - if( ImGui::Begin( title, &showWindow, ImGuiWindowFlags_ShowBorders ) ) + if( ImGui::Begin( title, &showWindow ) ) //, ImGuiWindowFlags_ShowBorders ) ) { bool changes = false;