• Advertisement
Sign in to follow this  

Java LWJGL Need Help Designing more efficient texture loading.

This topic is 1294 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I really need help with this, I'm building a 2d sandbox game and when you select a world size, it begins to load the textures and stuff needed to play, but depending on the world size, this can be long or short. For instance, if you choose Huge it takes 5+ min, the reason, I have a grid setup as an array, the bigger the world, the bigger the array, when every GridSpace initializes, it loads 2 textures, it's alpha and rgb, in reality, it's only 8 images, but these 8 images are being loaded hundreds to thousands of times, how can I setup it so It loads only once? (I'm using Slick-Utils and when it's a static Texture the Texture Load doesn't work, on can only be on non-static textures, and Getters and setters don't help)

Share this post


Link to post
Share on other sites
Advertisement

No Replies? I really need help with this, I will sometimes get a Too Many Files Exception, which is BAD because it just freezes and does nothing, and if you forget to save, worst nightmare!

Share this post


Link to post
Share on other sites

Have your texture loader cache your textures in a HashMap keyed on the file name. When you ask it to load a texture, it first checks the cache to see if the texture exists. If it does, it returns the existing instance rather than loading it from disk again.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement