Texture upload

I’ve got another question.



I have implemented a state based engine inspired by this thread:

http://www.mojomonkeycoding.com/jmeforum/viewtopic.php?t=484



Now I have written a small test application which has three states. State 1 and 2 have key bindings to jump to each other, whereas state 3 can be called from state 1 and 2 and returns to the state which called it.



What I experience now is that if I call state3 for the first time, there is a notable delay before it gets painted for the first time, which does not happen with the other two states. state 3 is the only state which has got a texture applied to some nodes.



Is it correct that textures only get uploaded to the graphics adapter memory when they are to be rendered the first time and not when the texture states are created? If so, can I change this behaviour, ie. make the texture be uploaded when I create it (eg. in some initialize code)? If not it means that every time a new model is displayed for the first time, there would be a delay.

If you want the texture memory to be placed on the graphics card before the actual rendering process, manually call apply() on the texture state. This will process the texture data and generate the texture id, etc.

That was what I was looking for, thanks.



BTW: is there some sort of "unapply" so that I can get rid of no longer needed textures?

In TextureState there is delete(int) and deleteAll(). delete(int) deletes a single texture defined by the position in the state, i.e. the first texture you add to the state is 0, next is 1 and so on.