diff --git a/src/main/java/com/mojang/minecraft/model/ModelPart.java b/src/main/java/com/mojang/minecraft/model/ModelPart.java index 2f61d76..699ee66 100644 --- a/src/main/java/com/mojang/minecraft/model/ModelPart.java +++ b/src/main/java/com/mojang/minecraft/model/ModelPart.java @@ -3,6 +3,9 @@ package com.mojang.minecraft.model; import com.mojang.minecraft.model.TexturedQuad; import com.mojang.minecraft.model.Vec3D; import com.mojang.minecraft.model.Vertex; + +import net.PeytonPlayz585.lwjgl.ModeBuffer; + import org.lwjgl.opengl.GL11; public final class ModelPart { @@ -128,7 +131,7 @@ public final class ModelPart { public void generateList(float var1) { this.list = GL11.glGenLists(1); GL11.glNewList(this.list, 4864); - GL11.glBegin(7); + GL11.glBeginQuery(7); for(int var2 = 0; var2 < this.quads.length; ++var2) { TexturedQuad var10000 = this.quads[var2]; @@ -140,12 +143,13 @@ public final class ModelPart { for(int var7 = 0; var7 < 4; ++var7) { Vertex var8; - GL11.glTexCoord2f((var8 = var4.vertices[var7]).u, var8.v); - GL11.glVertex3f(var8.vector.x * var3, var8.vector.y * var3, var8.vector.z * var3); + final ModeBuffer imb = new ModeBuffer(1024); + imb.glTexCoord2f((var8 = var4.vertices[var7]).u, var8.v); + imb.glVertex3f(var8.vector.x * var3, var8.vector.y * var3, var8.vector.z * var3); } } - GL11.glEnd(); + GL11.glEndQuery(); GL11.glEndList(); this.hasList = true; } diff --git a/src/main/java/net/PeytonPlayz585/lwjgl/ModeBuffer.java b/src/main/java/net/PeytonPlayz585/lwjgl/ModeBuffer.java new file mode 100644 index 0000000..5493a31 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/lwjgl/ModeBuffer.java @@ -0,0 +1,58 @@ +package net.PeytonPlayz585.lwjgl; + +import org.lwjgl.BufferUtils; + +import java.nio.FloatBuffer; + +/** + * Utility class that emulates immediate mode vertex data submission. + * Can be used to create VBO data. + */ +public final class ModeBuffer { + + private FloatBuffer buffer; + + public ModeBuffer(final int startSize) { + this.buffer = BufferUtils.createFloatBuffer(startSize); + } + + private void checkSize(final int count) { + while ( buffer.remaining() < count ) { + final FloatBuffer newBuffer = BufferUtils.createFloatBuffer(buffer.capacity() << 1); + buffer.flip(); + newBuffer.put(buffer); + buffer = newBuffer; + } + } + + public FloatBuffer getBuffer() { + buffer.flip(); + return buffer; + } + + public void glVertex2f(final float x, final float y) { + checkSize(2); + buffer.put(x).put(y); + } + + public void glVertex3f(final float x, final float y, final float z) { + checkSize(3); + buffer.put(x).put(y).put(z); + } + + public void glVertex4f(final float x, final float y, final float z, final float w) { + checkSize(4); + buffer.put(x).put(y).put(z).put(w); + } + + public void glNormal3f(final float x, final float y, final float z) { + checkSize(3); + buffer.put(x).put(y).put(z); + } + + public void glTexCoord2f(final float s, final float t) { + checkSize(2); + buffer.put(s).put(t); + } + +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java b/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java index f6d3ddc..f93af32 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java +++ b/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java @@ -1131,7 +1131,7 @@ public class GlStateManager extends LWJGL { } } - public static final void glMultiTexCoord2f(int p1, float p2, float p3) { + public static final void glMultiTexCoord2f(float p2, float p3) { tex0X = p2; tex0Y = p3; }