Fixed problems with newest ImGui version

This commit is contained in:
Robert Beckebans 2019-10-28 23:45:13 +01:00
parent 36fecdd783
commit d333370637
4 changed files with 45 additions and 21 deletions

View file

@ -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;
}
}

View file

@ -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

View file

@ -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)

View file

@ -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;