java - OpenGL - too many textures -
i have 90 frames animation , want display on minecraft hud. here code use now:
string ctype = "target"; int cspeed = 30; int fast = 0; public int centerroterycounter = 0; @forgesubscribe public void centerrotery(rendergameoverlayevent.post event){ //========resolution======== res = new scaledresolution(mc.gamesettings, mc.displaywidth, mc.displayheight); int width = res.getscaledwidth(); int height = res.getscaledheight(); //========resolution========+ if(centerroterycounter == 90){centerroterycounter = 0;} if(centerroterycounter < 10){ this.mc.renderengine.func_110577_a(new resourcelocation("centerrotery/"+ctype+"000" + centerroterycounter + ".png")); }else{if(centerroterycounter < 100){ this.mc.renderengine.func_110577_a(new resourcelocation("centerrotery/"+ctype+"00" + centerroterycounter + ".png")); }else{ this.mc.renderengine.func_110577_a(new resourcelocation("centerrotery/"+ctype+"0" + centerroterycounter + ".png")); } } drawtexturedmodalrect((width/2)-44, (height/2)-37, 0, 0, 250, 250); mc.func_110434_k().func_110577_a(gui.field_110324_m); if((fast % cspeed)==0){centerroterycounter++;}fast++; }
but can see, creating ~30 new resourcelocations every second..!! how can pre-load textures , display them same way?
you can use private static final hashmap class in method getresourcelocation(string resourcelocation). :
private static resourcelocation getresourcelocation(string resourcelocation) { resourcelocation myres = myhashmap.get(resourcelocation); if (myres == null) { myres = new resourcelocation(resourcelocation); myhashmap.put(resourcelocation, myres); } return myres; }
it cache resources on demand. sure of necessary amount of memory needed !
Comments
Post a Comment