Fixed Models (Again)
This commit is contained in:
parent
2e62e9b969
commit
84cea78151
|
@ -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.glemu.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 mb = new ModeBuffer(1024);
|
||||
mb.glTexCoord2f((var8 = var4.vertices[var7]).u, var8.v);
|
||||
mb.glVertex3f(var8.vector.x * var3, var8.vector.y * var3, var8.vector.z * var3);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnd();
|
||||
GL11.glEndQuery();
|
||||
GL11.glEndList();
|
||||
this.hasList = true;
|
||||
}
|
||||
|
|
58
src/teavm/java/net/PeytonPlayz585/glemu/ModeBuffer.java
Normal file
58
src/teavm/java/net/PeytonPlayz585/glemu/ModeBuffer.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package net.PeytonPlayz585.glemu;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import net.lax1dude.eaglercraft.GLAllocation;
|
||||
|
||||
/**
|
||||
* 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 = GLAllocation.createDirectFloatBuffer(startSize);
|
||||
}
|
||||
|
||||
private void checkSize(final int count) {
|
||||
while ( buffer.remaining() < count ) {
|
||||
final FloatBuffer newBuffer = GLAllocation.createDirectFloatBuffer(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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user