Textures: allowed backend to destroy texture while inside the NewFrame/EndFrame scope. (#8811)

This commit is contained in:
ocornut
2025-10-01 18:38:27 +02:00
parent fc4105c8a8
commit 8c22b8aef6
2 changed files with 10 additions and 4 deletions

View File

@@ -3491,8 +3491,10 @@ struct ImTextureData
ImTextureID GetTexID() const { return TexID; }
// Called by Renderer backend
void SetTexID(ImTextureID tex_id) { TexID = tex_id; } // Call after creating or destroying the texture. Never modify TexID directly!
void SetStatus(ImTextureStatus status) { Status = status; } // Call after honoring a request. Never modify Status directly!
// - Call SetTexID() and SetStatus() after honoring texture requests. Never modify TexID and Status directly!
// - A backend may decide to destroy a texture that we did not request to destroy, which is fine (e.g. freeing resources), but we immediately set the texture back in _WantCreate mode.
void SetTexID(ImTextureID tex_id) { TexID = tex_id; }
void SetStatus(ImTextureStatus status) { Status = status; if (status == ImTextureStatus_Destroyed && !WantDestroyNextFrame) Status = ImTextureStatus_WantCreate; }
};
//-----------------------------------------------------------------------------