mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 16:30:32 +00:00
dd06fcbbdf
- Added ImGuiTextureHandle that is implicitly convertible to ImTextureID and can be used directly with ImGui interface. - Added to ImGui Module interface allowing to register, update and release textures or find handles to existing resources. - Refactored Texture Manager and added functions allowing create, update or release resources for user textures. - Loosened resource verification policy in Texture Manager to work smoothly with external requests and to handle gracefully situations when invalid texture id is passed to ImGui. - Introduced ‘error texture’ that is used for invalid resources.
27 lines
894 B
C++
27 lines
894 B
C++
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
#include "ImGuiPrivatePCH.h"
|
|
|
|
#include "ImGuiTextureHandle.h"
|
|
|
|
#include "ImGuiInteroperability.h"
|
|
|
|
|
|
FImGuiTextureHandle::FImGuiTextureHandle()
|
|
: FImGuiTextureHandle(NAME_None, ImGuiInterops::ToImTextureID(INDEX_NONE))
|
|
{
|
|
}
|
|
|
|
FImGuiTextureHandle::FImGuiTextureHandle(const FName& InName, ImTextureID InTextureId)
|
|
: Name(InName)
|
|
, TextureId(InTextureId)
|
|
{
|
|
const TextureIndex Index = ImGuiInterops::ToTextureIndex(TextureId);
|
|
checkf((Index == INDEX_NONE) == (Name == NAME_None),
|
|
TEXT("Mismatch between Name and TextureId parameters, with only one indicating a null handle.")
|
|
TEXT(" Name = '%s', TextureIndex(TextureId) = %d"), *Name.ToString(), Index);
|
|
}
|
|
|
|
// FImGuiTextureHandle::HasValidEntry() is implemented in ImGuiModule.cpp to get access to FImGuiModuleManager instance
|
|
// without referencing in this class.
|