@@ -3103,7 +3103,9 @@ void RegisterTests_Layout(ImGuiTestEngine* e)
3103
3103
break ;
3104
3104
case ItemType_ImageButton:
3105
3105
expected_padding = style.FramePadding .y * 2 .0f ;
3106
- #if IMGUI_VERSION_NUM >= 18807
3106
+ #ifdef IMGUI_HAS_TEXTURES
3107
+ ImGui::ImageButton (" tex" , ImGui::GetIO ().Fonts ->TexRef , ImVec2 (100 , ImGui::GetTextLineHeight ()* label_line_count), ImVec2 (0 , 0 ), ImVec2 (1 , 1 ), ImVec4 (1 .0f , 0 .6f , 0 .0f , 1 .0f ));
3108
+ #elif IMGUI_VERSION_NUM >= 18807
3107
3109
ImGui::ImageButton (" tex" , ImGui::GetIO ().Fonts ->TexID , ImVec2 (100 , ImGui::GetTextLineHeight () * label_line_count), ImVec2 (0 , 0 ), ImVec2 (1 , 1 ), ImVec4 (1 .0f , 0 .6f , 0 .0f , 1 .0f ));
3108
3110
#else
3109
3111
ImGui::ImageButton (ImGui::GetIO ().Fonts ->TexID , ImVec2 (100 , ImGui::GetTextLineHeight () * label_line_count), ImVec2 (0 , 0 ), ImVec2 (1 , 1 ), -1 , ImVec4 (1 .0f , 0 .6f , 0 .0f , 1 .0f ));
@@ -3508,9 +3510,18 @@ struct HelpersTextureId
3508
3510
// Replace fake texture IDs with a known good ID in order to prevent graphics API crashing application.
3509
3511
void RemoveFakeTexFromDrawList (ImDrawList* draw_list, ImTextureID replacement_tex_id)
3510
3512
{
3513
+ #ifdef IMGUI_HAS_TEXTURES
3514
+ for (ImDrawCmd& cmd : draw_list->CmdBuffer )
3515
+ if (cmd.GetTexID () == FakeTex0 || cmd.GetTexID () == FakeTex1)
3516
+ {
3517
+ IM_ASSERT (cmd.TexRef ._TexData == NULL );
3518
+ cmd.TexRef ._TexID = replacement_tex_id;
3519
+ }
3520
+ #else
3511
3521
for (ImDrawCmd& cmd : draw_list->CmdBuffer )
3512
3522
if (cmd.TextureId == FakeTex0 || cmd.TextureId == FakeTex1)
3513
3523
cmd.TextureId = replacement_tex_id;
3524
+ #endif
3514
3525
}
3515
3526
};
3516
3527
@@ -3614,7 +3625,11 @@ void RegisterTests_DrawList(ImGuiTestEngine* e)
3614
3625
{
3615
3626
ImGui::Begin (" Test Window" , NULL , ImGuiWindowFlags_NoSavedSettings);
3616
3627
ImDrawList* draw_list = ImGui::GetWindowDrawList ();
3628
+ #ifdef IMGUI_HAS_TEXTURES
3629
+ ImTextureID prev_texture_id = draw_list->_TextureStack .back ().GetTexID ();
3630
+ #else
3617
3631
ImTextureID prev_texture_id = draw_list->_TextureIdStack .back ();
3632
+ #endif
3618
3633
const int start_cmdbuffer_size = draw_list->CmdBuffer .Size ;
3619
3634
IM_CHECK_EQ (draw_list->CmdBuffer .back ().ElemCount , 0u );
3620
3635
@@ -3632,7 +3647,11 @@ void RegisterTests_DrawList(ImGuiTestEngine* e)
3632
3647
3633
3648
IM_CHECK_EQ_NO_RET (draw_list->CmdBuffer .Size , start_cmdbuffer_size + 2 );
3634
3649
IM_CHECK_EQ_NO_RET (draw_list->CmdBuffer .back ().ElemCount , 0u );
3650
+ #ifdef IMGUI_HAS_TEXTURES
3651
+ IM_CHECK_NO_RET (prev_texture_id == draw_list->CmdBuffer .back ().GetTexID ());
3652
+ #else
3635
3653
IM_CHECK_NO_RET (prev_texture_id == draw_list->CmdBuffer .back ().TextureId );
3654
+ #endif
3636
3655
3637
3656
fake_tex.RemoveFakeTexFromDrawList (draw_list, prev_texture_id);
3638
3657
0 commit comments