Author Topic: get unloadTexture flag?  (Read 2788 times)

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
get unloadTexture flag?
« on: August 16, 2016, 05:46:43 pm »
i think it's good that TextureManager has a flag indicating whether a texture is loaded/unloaded, if one needs to strictly manage texture memory usage.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: get unloadTexture flag?
« Reply #1 on: August 16, 2016, 05:56:03 pm »
I'm not sure why this is needed. You can simply flag all unneeded textures for unload. It doesn't hurt if you do it on textures that aren't uploaded anyway.

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: get unloadTexture flag?
« Reply #2 on: August 16, 2016, 08:28:46 pm »
an unloaded texture is loaded again automatically when the object3d is rendered. this is not easily known by the  application, but the engine knows it , right?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: get unloadTexture flag?
« Reply #3 on: August 16, 2016, 11:19:59 pm »
Yes, but I don't get the point. Why do you have to know that?

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: get unloadTexture flag?
« Reply #4 on: August 17, 2016, 03:19:30 am »
because i have some large textures that i want to unload in a certain condition, and don't want them to be loaded accidentally.
i can write code like this:
if (Texture.isLoaded(frameBuffer)) TextureManager.unloadTexture(frameBuffer, texture);
but , i have other way : i can hide the object3d that has the texture, then the texture won't be loaded accidentally. so it's OK without knowing the flag.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: get unloadTexture flag?
« Reply #5 on: August 17, 2016, 09:27:27 am »
You can just call unload on them. It doesn't matter if they have been uploaded. If your condition to unload them is true, the internal state doesn't matter. The semantics are exactly the same: If it has been uploaded, unload it. If it hasn't, do nothing. It doesn't matter if you check before because the engine does it anyway.