Fixed Crash with ImGui when changing the resolution

This commit is contained in:
Robert Beckebans 2020-04-16 21:48:18 +02:00
parent 93710bd694
commit f92c3776ff
3 changed files with 17 additions and 6 deletions

View file

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

View file

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

View file

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