Jump to content

  • Log In with Google      Sign In   
  • Create Account


Java LWJGL Need Help Designing more efficient texture loading.

  • You cannot reply to this topic
3 replies to this topic

#1 coppyhop   Members   -  Reputation: 109

Like
0Likes
Like

Posted 06 July 2014 - 01:50 PM

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)



Sponsor:

#2 coppyhop   Members   -  Reputation: 109

Like
1Likes
Like

Posted 06 July 2014 - 07:35 PM

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!



#3 Aldacron   GDNet+   -  Reputation: 3055

Like
4Likes
Like

Posted 06 July 2014 - 07:44 PM

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.



#4 coppyhop   Members   -  Reputation: 109

Like
0Likes
Like

Posted 07 July 2014 - 04:03 PM

How can I do that?  I 'm new to LWJGL.







PARTNERS