Replace ShapeRenderer with old one

This commit is contained in:
PeytonPlayz595 2023-07-12 07:59:43 -04:00
parent a5957ad6b2
commit da1b7dac62

View File

@ -1,12 +1,13 @@
package com.mojang.minecraft.render;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import net.lax1dude.eaglercraft.GLAllocation;
public final class ShapeRenderer {
private FloatBuffer buffer = BufferUtils.createFloatBuffer(524288);
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(524288);
private float[] data = new float[524288];
private int vertices = 0;
private float u;
@ -16,6 +17,8 @@ public final class ShapeRenderer {
private float b;
private boolean color = false;
private boolean texture = false;
private boolean normals = false;
private int normal;
private int vertexLength = 3;
private int length = 0;
private boolean noColor = false;
@ -27,33 +30,31 @@ public final class ShapeRenderer {
this.buffer.clear();
this.buffer.put(this.data, 0, this.length);
this.buffer.flip();
if(this.texture && this.color) {
GL11.glInterleavedArrays(10794, 0, this.buffer);
} else if(this.texture) {
GL11.glInterleavedArrays(10791, 0, this.buffer);
} else if(this.color) {
GL11.glInterleavedArrays(10788, 0, this.buffer);
} else {
GL11.glInterleavedArrays(10785, 0, this.buffer);
if (this.texture) {
GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
}
GL11.glEnableClientState('\u8074');
if(this.texture) {
GL11.glEnableClientState('\u8078');
if (this.color) {
GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
}
if(this.color) {
GL11.glEnableClientState('\u8076');
if (this.normals) {
GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
}
GL11.glDrawArrays(7, 0, this.vertices);
GL11.glDisableClientState('\u8074');
if(this.texture) {
GL11.glDisableClientState('\u8078');
GL11._wglDrawArrays(7, 0, this.vertices);
if (this.texture) {
GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
}
if(this.color) {
GL11.glDisableClientState('\u8076');
if (this.color) {
GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
}
if (this.normals) {
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
}
}
@ -68,6 +69,7 @@ public final class ShapeRenderer {
public final void begin() {
this.clear();
this.normals = false;
this.color = false;
this.texture = false;
this.noColor = false;
@ -109,6 +111,10 @@ public final class ShapeRenderer {
this.data[this.length++] = this.b;
}
if(this.normals) {
this.data[this.length++] = this.normal;
}
this.data[this.length++] = var1;
this.data[this.length++] = var2;
this.data[this.length++] = var3;
@ -151,6 +157,12 @@ public final class ShapeRenderer {
}
public final void normal(float var1, float var2, float var3) {
this.normals = true;
float len = (float) Math.sqrt(var1 * var1 + var2 * var2 + var3 * var3);
int var4 = (int) ((var1 / len) * 127.0F) + 127;
int var5 = (int) ((var2 / len) * 127.0F) + 127;
int var6 = (int) ((var3 / len) * 127.0F) + 127;
this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16;
GL11.glNormal3f(var1, var2, var3);
}