www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: MichaelJPCT on August 16, 2016, 05:46:43 pm

Title: get unloadTexture flag?
Post by: MichaelJPCT 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.
Title: Re: get unloadTexture flag?
Post by: EgonOlsen 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.
Title: Re: get unloadTexture flag?
Post by: MichaelJPCT 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?
Title: Re: get unloadTexture flag?
Post by: EgonOlsen on August 16, 2016, 11:19:59 pm
Yes, but I don't get the point. Why do you have to know that?
Title: Re: get unloadTexture flag?
Post by: MichaelJPCT 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.
Title: Re: get unloadTexture flag?
Post by: EgonOlsen 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.