Update to use Display lists, significantly less calls to OpenGL. Cache rendering.
This commit is contained in:
parent
0af6bda540
commit
a3e2e6bb71
|
@ -10,9 +10,14 @@
|
|||
******************************************************************************/
|
||||
package cpw.mods.ironchest.client;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_COMPILE;
|
||||
import static org.lwjgl.opengl.GL11.glColor4f;
|
||||
import static org.lwjgl.opengl.GL11.glDisable;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
import static org.lwjgl.opengl.GL11.glEndList;
|
||||
import static org.lwjgl.opengl.GL11.glGenLists;
|
||||
import static org.lwjgl.opengl.GL11.glCallList;
|
||||
import static org.lwjgl.opengl.GL11.glNewList;
|
||||
import static org.lwjgl.opengl.GL11.glPopMatrix;
|
||||
import static org.lwjgl.opengl.GL11.glPushMatrix;
|
||||
import static org.lwjgl.opengl.GL11.glRotatef;
|
||||
|
@ -20,6 +25,8 @@ import static org.lwjgl.opengl.GL11.glScalef;
|
|||
import static org.lwjgl.opengl.GL11.glTranslatef;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.EntityItem;
|
||||
|
@ -37,6 +44,7 @@ import cpw.mods.ironchest.IronChestType;
|
|||
import cpw.mods.ironchest.TileEntityIronChest;
|
||||
|
||||
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||
private static Map<ItemStack, Integer> renderList = new HashMap<ItemStack, Integer>();
|
||||
private Random random;
|
||||
private RenderBlocks renderBlocks;
|
||||
|
||||
|
@ -146,6 +154,10 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
|||
glTranslatef(minishiftX, minishiftY, minishiftZ);
|
||||
}
|
||||
|
||||
if (renderList.get(item) == null) {
|
||||
int render = glGenLists(1);
|
||||
renderList.put(item, render);
|
||||
glNewList(render, GL_COMPILE);
|
||||
if (customRenderer != null) {
|
||||
customitem.item=item;
|
||||
bindTextureByName("/terrain.png");
|
||||
|
@ -188,6 +200,10 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
|||
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
|
||||
tessellator.draw();
|
||||
}
|
||||
} else {
|
||||
glCallList(renderList.get(item));
|
||||
}
|
||||
glEndList();
|
||||
glPopMatrix();
|
||||
}
|
||||
glPopMatrix();
|
||||
|
|
Loading…
Reference in New Issue