From f92c3776ff0ed5e6464473d7ed54d90957e079d9 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 16 Apr 2020 21:48:18 +0200 Subject: [PATCH] Fixed Crash with ImGui when changing the resolution --- base/renderprogs/ambient_lighting_IBL.ps.hlsl | 6 +++--- neo/imgui/BFGimguiImpl.cpp | 11 +++++++++++ neo/renderer/RenderProgs_embedded.h | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/base/renderprogs/ambient_lighting_IBL.ps.hlsl b/base/renderprogs/ambient_lighting_IBL.ps.hlsl index 73851144..6195e33d 100644 --- a/base/renderprogs/ambient_lighting_IBL.ps.hlsl +++ b/base/renderprogs/ambient_lighting_IBL.ps.hlsl @@ -143,10 +143,10 @@ void main( PS_IN fragment, out PS_OUT result ) #endif - float3 diffuseLight = ( texCUBE( samp7, globalNormal ).rgb ) * diffuseColor * ( rpDiffuseModifier.xyz ) * 3.5f; + float3 diffuseLight = ( texCUBE( samp7, globalNormal ).rgb ) * diffuseColor * ( rpDiffuseModifier.xyz ) * 3.5; - float mip = clamp( ( roughness * 7.0 ) + 3.0, 0.0, 10.0 ); - float3 envColor = ( textureLod( samp8, reflectionVector, mip ).rgb ) * ( rpSpecularModifier.xyz ) * 1.0f; + float mip = clamp( ( roughness * 7.0 ) + 0.0, 0.0, 10.0 ); + float3 envColor = ( textureLod( samp8, reflectionVector, mip ).rgb ) * ( rpSpecularModifier.xyz ) * 0.5; float3 specularLight = envColor * specularColor; diff --git a/neo/imgui/BFGimguiImpl.cpp b/neo/imgui/BFGimguiImpl.cpp index ca3be9f0..76f2c27b 100644 --- a/neo/imgui/BFGimguiImpl.cpp +++ b/neo/imgui/BFGimguiImpl.cpp @@ -282,6 +282,16 @@ void NotifyDisplaySizeChanged( int width, int height ) { Destroy(); Init( width, height ); + + // reuse the default ImGui font + idImage* image = globalImages->GetImage( "_imguiFont" ); + + ImGuiIO& io = ImGui::GetIO(); + + byte* pixels = NULL; + io.Fonts->GetTexDataAsRGBA32( &pixels, &width, &height ); + + io.Fonts->TexID = ( void* )( intptr_t )image->GetImGuiTextureID(); } } } @@ -437,6 +447,7 @@ void Destroy() { ImGui::DestroyContext(); g_IsInit = false; + g_haveNewFrame = false; } } diff --git a/neo/renderer/RenderProgs_embedded.h b/neo/renderer/RenderProgs_embedded.h index 0eec8367..c258f09d 100644 --- a/neo/renderer/RenderProgs_embedded.h +++ b/neo/renderer/RenderProgs_embedded.h @@ -2337,10 +2337,10 @@ static const cgShaderDef_t cg_renderprogs[] = "\n" "#endif\n" " \n" - " float3 diffuseLight = ( texCUBE( samp7, globalNormal ).rgb ) * diffuseColor * ( rpDiffuseModifier.xyz ) * 3.5f;\n" + " float3 diffuseLight = ( texCUBE( samp7, globalNormal ).rgb ) * diffuseColor * ( rpDiffuseModifier.xyz ) * 3.5;\n" " \n" - " float mip = clamp( ( roughness * 7.0 ) + 3.0, 0.0, 10.0 );\n" - " float3 envColor = ( textureLod( samp8, reflectionVector, mip ).rgb ) * ( rpSpecularModifier.xyz ) * 1.0f;\n" + " float mip = clamp( ( roughness * 7.0 ) + 0.0, 0.0, 10.0 );\n" + " float3 envColor = ( textureLod( samp8, reflectionVector, mip ).rgb ) * ( rpSpecularModifier.xyz ) * 0.5;\n" " \n" " float3 specularLight = envColor * specularColor;\n" " \n"