extensions/graphics3d: Working texture loading
This commit is contained in:
parent
3176478881
commit
f4862fdc0d
@ -46,7 +46,23 @@ M.safe.ScenePrimitive = polybox.wrap_class("ScenePrimitive", {
|
||||
unsafe = polybox.check_type(safe, "ScenePrimitive")
|
||||
polybox.check_type(texture_name, "string")
|
||||
local path = __buildat_get_file_path(texture_name)
|
||||
unsafe:loadTexture(path)
|
||||
-- HACK: Create temporary file with the original file extension to
|
||||
-- make Polycode load it directly
|
||||
local hash_hex = string.match(path, '/([a-zA-Z0-9]+)$')
|
||||
local ext = string.match(texture_name, '\.([a-zA-Z0-9]+)$')
|
||||
log:info("File hash_hex="..dump(hash_hex).." extension"..dump(ext))
|
||||
local path2 = __buildat_get_path("tmp").."/"..hash_hex.."."..ext
|
||||
log:info("Temporary path: "..path2)
|
||||
local src = io.open(path, "rb")
|
||||
local dst = io.open(path2, "wb")
|
||||
while true do
|
||||
local buf = src:read(100000)
|
||||
if buf == nil then break end
|
||||
dst:write(buf)
|
||||
end
|
||||
src:close()
|
||||
dst:close()
|
||||
unsafe:loadTexture(path2)
|
||||
end,
|
||||
setPosition = function(safe, x, y, z)
|
||||
unsafe = polybox.check_type(safe, "ScenePrimitive")
|
||||
|
BIN
test/testmodules/test1/client_data/green_texture.png
Normal file
BIN
test/testmodules/test1/client_data/green_texture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
BIN
test/testmodules/test1/client_data/pink_texture.png
Normal file
BIN
test/testmodules/test1/client_data/pink_texture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Loading…
x
Reference in New Issue
Block a user