Loading Images

#1

I have an image and it’s assigned to Node “Imagery”

I have this code in a function called DeleteScene:

gui.delete_texture("placeimage")
gui.delete_node(imagery)

Then when it’s done I call a new SceneRender(SceneID) where scene is a index to an array contain scene information such as the background image to load.

That function has code:

–//LOAD BACKGROUND
–//better abstraction and scene globalization of background image
local new_position = vmath.vector3(0, 0, 0)
local new_size = vmath.vector3(ScrollScenes.ScrollScene[SceneID].Background.Xsize, ScrollScenes.ScrollScene[SceneID].Background.Ysize, 0)

imagery = gui.new_box_node(new_position, new_size)
gui.set_parent(imagery, gui.get_node("viewport1"))

local filetoload = ScrollScenes.ScrollScene[SceneID].Background.Filename
print("LOADING..."..filetoload)
local png = UILoadImageFile(filetoload, "scene-backgrounds")
gui.new_texture("placeimage", png.width, png.height, "rgba", png.buffer)	
gui.set_texture(imagery, "placeimage")
print("Background Loaded!")

But what’s happening is that despite clearly deleting the texture, and the box node associated with it, the system is loading the previous image not the new image.

It’s like it revives the previous image from the dead. Any idea what I’m not doing right?

0 Likes

#2

I looked into this yesterday evening and the problem was that the code did a gui.delete_texture() and gui.new_texture() in the same frame and using the same texture id. Using a different texture id each time solved the problem.

2 Likes