mirror of
https://github.com/ocornut/imgui.git
synced 2026-03-23 09:00:54 +00:00
Textures: Detect when using a texture that's about to be destroyed.
This commit is contained in:
@@ -15733,7 +15733,10 @@ void ImGui::DebugNodeTexture(ImTextureData* tex)
|
||||
Checkbox("Show used rect", &cfg->ShowTextureUsedRect);
|
||||
PushStyleVar(ImGuiStyleVar_ImageBorderSize, ImMax(1.0f, g.Style.ImageBorderSize));
|
||||
ImVec2 p = GetCursorScreenPos();
|
||||
ImageWithBg(tex->GetTexRef(), ImVec2((float)tex->Width, (float)tex->Height), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), ImVec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
if (tex->WantDestroyNextFrame)
|
||||
Dummy(ImVec2((float)tex->Width, (float)tex->Height));
|
||||
else
|
||||
ImageWithBg(tex->GetTexRef(), ImVec2((float)tex->Width, (float)tex->Height), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), ImVec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
if (cfg->ShowTextureUsedRect)
|
||||
GetWindowDrawList()->AddRect(ImVec2(p.x + tex->UsedRect.x, p.y + tex->UsedRect.y), ImVec2(p.x + tex->UsedRect.x + tex->UsedRect.w, p.y + tex->UsedRect.y + tex->UsedRect.h), IM_COL32(255, 0, 255, 255));
|
||||
PopStyleVar();
|
||||
|
||||
@@ -676,6 +676,8 @@ void ImDrawList::PushTexture(ImTextureRef tex_ref)
|
||||
{
|
||||
_TextureStack.push_back(tex_ref);
|
||||
_CmdHeader.TexRef = tex_ref;
|
||||
if (tex_ref._TexData != NULL)
|
||||
IM_ASSERT(tex_ref._TexData->WantDestroyNextFrame == false);
|
||||
_OnChangedTexture();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user