Skip to content

Commit ec27029

Browse files
committed
Fix RTT texture reference format for RmlUi
Corrected the texture reference format to use RmlUi's proper syntax: - Changed from `:t{texID}` format to `!{texID}` format - Use `<texture>` tag instead of `<img>` for GL textures - Keep `<img>` for regular file paths RmlUi Texture Reference Format: - String starting with "!": texture reference (!texID) * Use <texture src="!{texID}"> for dynamic GL textures - Number: OpenGL texture ID from gl.CreateTexture * Convert to "!{texID}" format - Regular string path: standard image file * Use <img src="{path}"> as before This matches Recoil's RmlUi integration where: - gl.CreateTexture() returns a texID (number) - Reference it in RML as src="!{texID}" - The <texture> element displays the GL texture - Dynamic updates via gl.RenderToTexture work automatically Now RTT 3D model previews should display correctly in Objects tab.
1 parent 9c700c9 commit ec27029

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

scen_edit/view/grid_view.lua

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -458,19 +458,25 @@ function GridView:_UpdateRmlUiGrid()
458458
local imagePath = item.image
459459
-- Handle both file paths (strings) and texture IDs (numbers/tables)
460460
if type(imagePath) == "string" then
461-
-- Regular file path
462-
if imagePath:sub(1, 6) == "LuaUI/" then
463-
imagePath = "../../../" .. imagePath
461+
-- Check if it's already a texture reference (!texID format)
462+
if imagePath:sub(1, 1) == "!" then
463+
-- Already a texture reference from gl.CreateTexture, use <texture> tag
464+
html = html .. string.format('<texture src="%s" class="grid-item-image"/>', imagePath)
465+
else
466+
-- Regular file path
467+
if imagePath:sub(1, 6) == "LuaUI/" then
468+
imagePath = "../../../" .. imagePath
469+
end
470+
html = html .. string.format('<img src="%s" class="grid-item-image"/>', imagePath)
464471
end
465-
html = html .. string.format('<img src="%s" class="grid-item-image"/>', imagePath)
466472
elseif type(imagePath) == "number" then
467-
-- OpenGL texture ID - RmlUi should support this directly
468-
-- Format: :t<textureID> for Spring texture references
469-
html = html .. string.format('<img src=":t%d" class="grid-item-image"/>', imagePath)
473+
-- OpenGL texture ID from gl.CreateTexture
474+
-- Format: !<texID> for RmlUi texture references, use <texture> tag
475+
html = html .. string.format('<texture src="!%d" class="grid-item-image"/>', imagePath)
470476
else
471477
-- Texture table/object - try to extract ID or convert to string
472478
local texId = imagePath.texID or imagePath.id or tostring(imagePath)
473-
html = html .. string.format('<img src=":t%s" class="grid-item-image"/>', tostring(texId))
479+
html = html .. string.format('<texture src="!%s" class="grid-item-image"/>', tostring(texId))
474480
end
475481
end
476482

0 commit comments

Comments
 (0)