MCPcopy Create free account
hub / github.com/Norbyte/bg3se / BindIcon

Method BindIcon

BG3Extender/Extender/Client/IMGUI/IMGUI.cpp:60–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60bool ImageReference::BindIcon(FixedString const& iconName)
61{
62 auto atlas = (*GetStaticSymbols().ls__gTextureAtlasMap)->IconMap.get_or_default(iconName);
63 if (!atlas) {
64 return false;
65 }
66
67 auto uvs = atlas->Icons.get_or_default(iconName);
68 if (!uvs) {
69 WARN("Failed to find UVs for icon '%s'", iconName.GetString());
70 return false;
71 }
72
73 auto texture = gExtender->IMGUI().RegisterTexture(atlas->TextureUuid);
74 if (!texture) {
75 WARN("Failed to load texture '%s' for icon '%s'", atlas->TextureUuid.GetString(), iconName.GetString());
76 return false;
77 }
78
79 Size = glm::vec2(
80 static_cast<float>(atlas->IconWidth),
81 static_cast<float>(atlas->IconHeight)
82 );
83
84 UV0 = uvs->UV0;
85 UV1 = uvs->UV1;
86
87 TextureResource = atlas->TextureUuid;
88 Icon = iconName;
89 TextureHandle = texture->OpaqueHandle;
90 return true;
91}
92
93ImTextureID ImageReference::PrepareRender()
94{

Callers

nothing calls this directly

Calls 3

GetStringMethod · 0.80
RegisterTextureMethod · 0.80
get_or_defaultMethod · 0.45

Tested by

no test coverage detected