mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Textures: Detect when using a texture that's about to be destroyed.
This commit is contained in:
parent
0b71339122
commit
131f5c57ab
2 changed files with 6 additions and 1 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue