diff --git a/src/main/java/alexiil/mc/mod/load/baked/render/BakedImageRender.java b/src/main/java/alexiil/mc/mod/load/baked/render/BakedImageRender.java index af0c2f1..84c3115 100644 --- a/src/main/java/alexiil/mc/mod/load/baked/render/BakedImageRender.java +++ b/src/main/java/alexiil/mc/mod/load/baked/render/BakedImageRender.java @@ -12,10 +12,19 @@ import buildcraft.lib.expression.node.value.NodeVariableDouble; public class BakedImageRender extends BakedRenderPositioned { + + /** We only ever render 4 x (3 pos, 2 uv) ints each time then reset for the next face. + *
+ * So this 64 is overkill. */ + private static final int TESS_INT_COUNT = 0x40; + + private final Tessellator tess = new Tessellator(TESS_INT_COUNT); + protected final ResourceLocation res; private final BakedArea pos, tex; - public BakedImageRender(NodeVariableDouble varWidth, NodeVariableDouble varHeight, String res, BakedArea pos, BakedArea tex) { + public BakedImageRender(NodeVariableDouble varWidth, NodeVariableDouble varHeight, String res, BakedArea pos, + BakedArea tex) { super(varWidth, varHeight); this.res = new ResourceLocation(res); this.pos = pos; @@ -33,14 +42,13 @@ public void evaluateVariables(MinecraftDisplayerRenderer renderer) { @Override public void render(MinecraftDisplayerRenderer renderer) { bindTexture(renderer); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder vb = tessellator.getBuffer(); + BufferBuilder vb = tess.getBuffer(); vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); vb.pos(pos._x, pos._y + pos._h, 0).tex(tex._x, tex._y + tex._h).endVertex(); vb.pos(pos._x + pos._w, pos._y + pos._h, 0).tex(tex._x + tex._w, tex._y + tex._h).endVertex(); vb.pos(pos._x + pos._w, pos._y, 0).tex(tex._x + tex._w, tex._y).endVertex(); vb.pos(pos._x, pos._y, 0).tex(tex._x, tex._y).endVertex(); - tessellator.draw(); + tess.draw(); } public void bindTexture(MinecraftDisplayerRenderer renderer) {