So, I have a problem when rapidly loading and unloading textures in a multithreaded environment with several viewports, worlds, etc
In particular the problem occurs when unloading a texture, then immediately loading it again (same image and name) and creating an object that uses the texture (all without redraw). The texture then appears without the texture and is colored in the setAdditionalColor(...) color. I suspect that the texture doesn't get unloaded from the FrameBuffer. However when I add another object with the same texture "a little bit later" (after redraw), it is textured fine.
I tried to create a simple test case, but no luck. The workaround I have now is that I use
if (textureManager.containsTexture(name)) {
textureManager.replaceTexture(name, texture);
} else {
textureManager.addTexture(name, texture);
textureManager.replaceTexture(name, texture);
}
Will this cause a lot of extra load? How bad practice is this?
Thank you!