Page 1 of 1

gl.Texture no cache

Posted: 05 Apr 2015, 11:14
by gajop
Is there any way to disable gl.Texture caching?
My use case is:

Code: Select all

-- user loads texture
gl.Texture(path)
gl.RenderToTexture(fboTex, function() ... end)
gl.Texture(false)

-- user saves texture
os.remove(path) -- remove old texture
gl.RenderToTexture(fboTex, gl.SaveImage, 0, 0, texSize, texSize, path)

-- user loads texture again
gl.Texture(path)
gl.RenderToTexture(fboTex, function() ... end)
gl.Texture(false)
Problem happens when I load a texture again from the same path even though the texture has changed in the meanwhile. It will still give me the cached texture instead of the new texture. Is there any option to disable the caching and enforce that it loads it from the disk?
Thanks.

Re: gl.Texture no cache

Posted: 05 Apr 2015, 11:18
by gajop
To offer one (ugly) solution myself is:
gl.Texture(":"..os.clock()..":" .. path)

Re: gl.Texture no cache

Posted: 05 Apr 2015, 14:19
by jK
use gl.DeleteTexture

Re: gl.Texture no cache

Posted: 05 Apr 2015, 14:27
by gajop
OK, so are supposed to gl.DeleteTexture those that we haven't gl.CreateTexture-d or is it just to enforce no caching?
Also, what does gl.DeleteTextureFBO do? delete the FBO of a texture fbo=true texture or delete the texture+fbo of a fbo=true texture?

Re: gl.Texture no cache

Posted: 05 Apr 2015, 15:09
by jK
with gl.DeleteTexture you can delete named textures (that's the name of them), too.

Re: gl.Texture no cache

Posted: 05 Apr 2015, 15:22
by gajop
Right, I got that now.
1. The next question is whether this (deleting named textures) is something we should do to prevent memory leaks?
From what I understand Lua textures (gl.CreateTexture) are one of the rare few things that we need to explicitly delete in Lua.
And:
2.
Also, what does gl.DeleteTextureFBO do? delete the FBO of a texture fbo=true texture or delete the texture+fbo of a fbo=true texture?

Re: gl.Texture no cache

Posted: 05 Apr 2015, 16:53
by jK
@1: when you load a huge loadscreen texture in LuaIntro and later never need it again, then yes you should delete it in :Shutdown()

@2: you got the source

Re: gl.Texture no cache

Posted: 06 Apr 2015, 01:56
by gajop
jK wrote:@1: when you load a huge loadscreen texture in LuaIntro and later never need it again, then yes you should delete it in :Shutdown()
I understand that I should sometimes delete it, but the question was really whether named textures will be deleted automatically after some time or not. That is, will gl.Texture(path) remain in memory forever until gl.DeleteTexture(path) or would they be removed by Spring?
jK wrote: @2: you got the source
:P

PS: Another question: Is there a way to monitor widget/gadget memory usage, including the use of textures which doesn't fall in the 800~ish MBs allocated to Lua?