mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-02-22 12:10:33 +00:00
Support for general UTexture instead of being limited to Texture2D for ImGui interop
This commit is contained in:
parent
fa7134f553
commit
2b8f3e55c3
@ -84,7 +84,7 @@ FImGuiTextureHandle FImGuiModule::FindTextureHandle(const FName& Name)
|
||||
return (Index != INDEX_NONE) ? FImGuiTextureHandle{ Name, ImGuiInterops::ToImTextureID(Index) } : FImGuiTextureHandle{};
|
||||
}
|
||||
|
||||
FImGuiTextureHandle FImGuiModule::RegisterTexture(const FName& Name, class UTexture2D* Texture, bool bMakeUnique)
|
||||
FImGuiTextureHandle FImGuiModule::RegisterTexture(const FName& Name, class UTexture* Texture, bool bMakeUnique)
|
||||
{
|
||||
FTextureManager& TextureManager = ImGuiModuleManager->GetTextureManager();
|
||||
|
||||
|
@ -27,7 +27,7 @@ TextureIndex FTextureManager::CreatePlainTexture(const FName& Name, int32 Width,
|
||||
return CreatePlainTextureInternal(Name, Width, Height, Color);
|
||||
}
|
||||
|
||||
TextureIndex FTextureManager::CreateTextureResources(const FName& Name, UTexture2D* Texture)
|
||||
TextureIndex FTextureManager::CreateTextureResources(const FName& Name, UTexture* Texture)
|
||||
{
|
||||
checkf(Name != NAME_None, TEXT("Trying to create texture resources with a name 'NAME_None' is not allowed."));
|
||||
checkf(Texture, TEXT("Null Texture."));
|
||||
@ -87,7 +87,7 @@ TextureIndex FTextureManager::CreatePlainTextureInternal(const FName& Name, int3
|
||||
return CreateTextureInternal(Name, Width, Height, Bpp, SrcData, SrcDataCleanup);
|
||||
}
|
||||
|
||||
TextureIndex FTextureManager::AddTextureEntry(const FName& Name, UTexture2D* Texture, bool bAddToRoot)
|
||||
TextureIndex FTextureManager::AddTextureEntry(const FName& Name, UTexture* Texture, bool bAddToRoot)
|
||||
{
|
||||
// Try to find an entry with that name.
|
||||
TextureIndex Index = FindTextureIndex(Name);
|
||||
@ -110,7 +110,7 @@ TextureIndex FTextureManager::AddTextureEntry(const FName& Name, UTexture2D* Tex
|
||||
}
|
||||
}
|
||||
|
||||
FTextureManager::FTextureEntry::FTextureEntry(const FName& InName, UTexture2D* InTexture, bool bAddToRoot)
|
||||
FTextureManager::FTextureEntry::FTextureEntry(const FName& InName, UTexture* InTexture, bool bAddToRoot)
|
||||
: Name(InName)
|
||||
{
|
||||
checkf(InTexture, TEXT("Null texture."));
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
// @param Name - The texture name
|
||||
// @param Texture - The texture
|
||||
// @returns The index to created/updated texture resources
|
||||
TextureIndex CreateTextureResources(const FName& Name, UTexture2D* Texture);
|
||||
TextureIndex CreateTextureResources(const FName& Name, UTexture* Texture);
|
||||
|
||||
// Release resources for given texture. Ignores invalid indices.
|
||||
// @param Index - The index of a texture resources
|
||||
@ -107,7 +107,7 @@ private:
|
||||
// @param Texture - The texture
|
||||
// @param bAddToRoot - If true, we should add texture to root to prevent garbage collection (use for own textures)
|
||||
// @returns The index of the entry that we created or reused
|
||||
TextureIndex AddTextureEntry(const FName& Name, UTexture2D* Texture, bool bAddToRoot);
|
||||
TextureIndex AddTextureEntry(const FName& Name, UTexture* Texture, bool bAddToRoot);
|
||||
|
||||
// Check whether index is in range allocated for TextureResources (it doesn't mean that resources are valid).
|
||||
FORCEINLINE bool IsInRange(TextureIndex Index) const
|
||||
@ -125,7 +125,7 @@ private:
|
||||
struct FTextureEntry
|
||||
{
|
||||
FTextureEntry() = default;
|
||||
FTextureEntry(const FName& InName, UTexture2D* InTexture, bool bAddToRoot);
|
||||
FTextureEntry(const FName& InName, UTexture* InTexture, bool bAddToRoot);
|
||||
~FTextureEntry();
|
||||
|
||||
// Copying is not supported.
|
||||
@ -146,7 +146,7 @@ private:
|
||||
|
||||
FName Name = NAME_None;
|
||||
mutable FSlateResourceHandle CachedResourceHandle;
|
||||
TWeakObjectPtr<UTexture2D> Texture;
|
||||
TWeakObjectPtr<UTexture> Texture;
|
||||
FSlateBrush Brush;
|
||||
};
|
||||
|
||||
|
@ -108,7 +108,7 @@ public:
|
||||
* @returns Handle to the texture resources, which can be used to release allocated resources and as an argument to
|
||||
* relevant ImGui functions
|
||||
*/
|
||||
virtual FImGuiTextureHandle RegisterTexture(const FName& Name, class UTexture2D* Texture, bool bMakeUnique = false);
|
||||
virtual FImGuiTextureHandle RegisterTexture(const FName& Name, class UTexture* Texture, bool bMakeUnique = false);
|
||||
|
||||
/**
|
||||
* Unregister texture and release its Slate resources. If handle is null or not valid, this function fails silently
|
||||
|
Loading…
Reference in New Issue
Block a user