Skip to content

Commit ebf94e9

Browse files
committed
TestSuite, imgui_app: fixes for WIP 1.92 branch.
1 parent 5a94055 commit ebf94e9

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

imgui_test_suite/imgui_tests_core.cpp

+20-1
Original file line numberDiff line numberDiff line change
@@ -3103,7 +3103,9 @@ void RegisterTests_Layout(ImGuiTestEngine* e)
31033103
break;
31043104
case ItemType_ImageButton:
31053105
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
31073109
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));
31083110
#else
31093111
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
35083510
// Replace fake texture IDs with a known good ID in order to prevent graphics API crashing application.
35093511
void RemoveFakeTexFromDrawList(ImDrawList* draw_list, ImTextureID replacement_tex_id)
35103512
{
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
35113521
for (ImDrawCmd& cmd : draw_list->CmdBuffer)
35123522
if (cmd.TextureId == FakeTex0 || cmd.TextureId == FakeTex1)
35133523
cmd.TextureId = replacement_tex_id;
3524+
#endif
35143525
}
35153526
};
35163527

@@ -3614,7 +3625,11 @@ void RegisterTests_DrawList(ImGuiTestEngine* e)
36143625
{
36153626
ImGui::Begin("Test Window", NULL, ImGuiWindowFlags_NoSavedSettings);
36163627
ImDrawList* draw_list = ImGui::GetWindowDrawList();
3628+
#ifdef IMGUI_HAS_TEXTURES
3629+
ImTextureID prev_texture_id = draw_list->_TextureStack.back().GetTexID();
3630+
#else
36173631
ImTextureID prev_texture_id = draw_list->_TextureIdStack.back();
3632+
#endif
36183633
const int start_cmdbuffer_size = draw_list->CmdBuffer.Size;
36193634
IM_CHECK_EQ(draw_list->CmdBuffer.back().ElemCount, 0u);
36203635

@@ -3632,7 +3647,11 @@ void RegisterTests_DrawList(ImGuiTestEngine* e)
36323647

36333648
IM_CHECK_EQ_NO_RET(draw_list->CmdBuffer.Size, start_cmdbuffer_size + 2);
36343649
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
36353653
IM_CHECK_NO_RET(prev_texture_id == draw_list->CmdBuffer.back().TextureId);
3654+
#endif
36363655

36373656
fake_tex.RemoveFakeTexFromDrawList(draw_list, prev_texture_id);
36383657

shared/imgui_app.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static void ImGuiApp_ImplNull_Render(ImGuiApp* app_opaque)
227227
{
228228
if (tex->Status == ImTextureStatus_WantCreate)
229229
{
230-
tex->SetTexUserID(0x42424242);
230+
tex->SetTexID(0x42424242);
231231
tex->Status = ImTextureStatus_OK;
232232
}
233233
if (tex->Status == ImTextureStatus_WantUpdates)
@@ -236,7 +236,7 @@ static void ImGuiApp_ImplNull_Render(ImGuiApp* app_opaque)
236236
}
237237
if (tex->Status == ImTextureStatus_WantDestroy)
238238
{
239-
tex->SetTexUserID(ImTextureUserID_Invalid);
239+
tex->SetTexID(ImTextureID_Invalid);
240240
tex->Status = ImTextureStatus_Destroyed;
241241
}
242242
}

0 commit comments

Comments
 (0)