1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

Textures: fixed displaying texture # in metrics/debugger.

This commit is contained in:
ocornut 2025-11-26 14:18:51 +01:00
parent 3fef0d553d
commit e768f91dc2
2 changed files with 6 additions and 13 deletions

View file

@ -50,6 +50,7 @@ Other Changes:
the oldest bug in Dear ImGui history (albeit for a rarely used feature)! (#9086) the oldest bug in Dear ImGui history (albeit for a rarely used feature)! (#9086)
- Textures: - Textures:
- Fixed a building issue when ImTextureID is defined as a struct. - Fixed a building issue when ImTextureID is defined as a struct.
- Fixed displaying texture # in Metrics/Debugger window.
- Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be - Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be
noticeable by user but detected by sanitizers). (#9089) [@judicaelclair] noticeable by user but detected by sanitizers). (#9089) [@judicaelclair]
- Backends: - Backends:

View file

@ -16124,26 +16124,18 @@ void ImGui::UpdateDebugToolFlashStyleColor()
ImU64 ImGui::DebugTextureIDToU64(ImTextureID tex_id) ImU64 ImGui::DebugTextureIDToU64(ImTextureID tex_id)
{ {
ImU64 v = 0; ImU64 v = 0;
memcpy(&v, &tex_id, ImMin(sizeof(ImU64), sizeof(tex_id))); memcpy(&v, &tex_id, ImMin(sizeof(ImU64), sizeof(ImTextureID)));
return v; return v;
} }
static const char* FormatTextureIDForDebugDisplay(char* buf, int buf_size, ImTextureID tex_id)
{
ImU64 v = ImGui::DebugTextureIDToU64(tex_id);
if (sizeof(tex_id) >= sizeof(void*))
ImFormatString(buf, buf_size, "0x%p", v);
else
ImFormatString(buf, buf_size, "0x%04X", v);
return buf;
}
static const char* FormatTextureRefForDebugDisplay(char* buf, int buf_size, ImTextureRef tex_ref) static const char* FormatTextureRefForDebugDisplay(char* buf, int buf_size, ImTextureRef tex_ref)
{ {
char* buf_p = buf;
char* buf_end = buf + buf_size; char* buf_end = buf + buf_size;
if (tex_ref._TexData != NULL) if (tex_ref._TexData != NULL)
buf += ImFormatString(buf, buf_end - buf, "#%03d: ", tex_ref._TexData->UniqueID); buf_p += ImFormatString(buf_p, buf_end - buf_p, "#%03d: ", tex_ref._TexData->UniqueID);
return FormatTextureIDForDebugDisplay(buf, (int)(buf_end - buf), tex_ref.GetTexID()); buf_p += ImFormatString(buf_p, buf_end - buf_p, "0x%X", ImGui::DebugTextureIDToU64(tex_ref.GetTexID()));
return buf;
} }
#ifdef IMGUI_ENABLE_FREETYPE #ifdef IMGUI_ENABLE_FREETYPE