I mean... It kinda works... ¯\_(ツ)_/¯

The Shape Renderer is fucked up but it still works... kinda
This commit is contained in:
PeytonPlayz595 2023-07-11 11:20:28 -04:00
parent eb7a5b3ad2
commit 2942b2fd7b

View File

@ -16,6 +16,8 @@ public final class ShapeRenderer {
private float b; private float b;
private boolean color = false; private boolean color = false;
private boolean texture = false; private boolean texture = false;
private boolean normals = false;
private int normal;
private int vertexLength = 3; private int vertexLength = 3;
private int length = 0; private int length = 0;
private boolean noColor = false; private boolean noColor = false;
@ -23,38 +25,34 @@ public final class ShapeRenderer {
public final void end() { public final void end() {
if(this.vertices > 0) {
this.buffer.clear(); this.buffer.clear();
this.buffer.put(this.data, 0, this.length); this.buffer.put(this.data, 0, this.length);
this.buffer.flip(); this.buffer.flip();
if(this.texture && this.color) {
GL11.glInterleavedArrays(10794, 0, this.buffer); if (this.texture) {
} else if(this.texture) { GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
GL11.glInterleavedArrays(10791, 0, this.buffer);
} else if(this.color) {
GL11.glInterleavedArrays(10788, 0, this.buffer);
} else {
GL11.glInterleavedArrays(10785, 0, this.buffer);
} }
GL11.glEnableClientState('\u8074'); if (this.color) {
if(this.texture) { GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
GL11.glEnableClientState('\u8078');
} }
if(this.color) { if (this.normals) {
GL11.glEnableClientState('\u8076'); GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
} }
GL11.glDrawArrays(7, 0, this.vertices); GL11._wglDrawArrays(7, 0, this.vertices);
GL11.glDisableClientState('\u8074');
if(this.texture) { if (this.texture) {
GL11.glDisableClientState('\u8078'); GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
} }
if(this.color) { if (this.color) {
GL11.glDisableClientState('\u8076'); GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
} }
if (this.normals) {
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
} }
this.clear(); this.clear();
@ -68,6 +66,7 @@ public final class ShapeRenderer {
public final void begin() { public final void begin() {
this.clear(); this.clear();
this.normals = false;
this.color = false; this.color = false;
this.texture = false; this.texture = false;
this.noColor = false; this.noColor = false;
@ -109,6 +108,10 @@ public final class ShapeRenderer {
this.data[this.length++] = this.b; this.data[this.length++] = this.b;
} }
if(this.normals) {
this.data[this.length++] = this.normal;
}
this.data[this.length++] = var1; this.data[this.length++] = var1;
this.data[this.length++] = var2; this.data[this.length++] = var2;
this.data[this.length++] = var3; this.data[this.length++] = var3;
@ -151,6 +154,12 @@ public final class ShapeRenderer {
} }
public final void normal(float var1, float var2, float var3) { 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); GL11.glNormal3f(var1, var2, var3);
} }