extensions/graphics3d: Working texture loading

This commit is contained in:
Perttu Ahola 2014-09-19 15:48:03 +03:00
parent 3176478881
commit f4862fdc0d
3 changed files with 17 additions and 1 deletions

View File

@ -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")

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB