UnrealImGui/Source/ImGui/Private/ImGuiTextureHandle.cpp
Sebastian dd06fcbbdf Added support for registering in module user textures to them in ImGui:
- 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.
2018-08-15 22:20:46 +01:00

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.