Replace ShapeRenderer with old one
This commit is contained in:
parent
a5957ad6b2
commit
da1b7dac62
|
@ -1,157 +1,169 @@
|
||||||
package com.mojang.minecraft.render;
|
package com.mojang.minecraft.render;
|
||||||
|
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
import net.lax1dude.eaglercraft.GLAllocation;
|
||||||
public final class ShapeRenderer {
|
|
||||||
|
public final class ShapeRenderer {
|
||||||
private FloatBuffer buffer = BufferUtils.createFloatBuffer(524288);
|
|
||||||
private float[] data = new float[524288];
|
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(524288);
|
||||||
private int vertices = 0;
|
private float[] data = new float[524288];
|
||||||
private float u;
|
private int vertices = 0;
|
||||||
private float v;
|
private float u;
|
||||||
private float r;
|
private float v;
|
||||||
private float g;
|
private float r;
|
||||||
private float b;
|
private float g;
|
||||||
private boolean color = false;
|
private float b;
|
||||||
private boolean texture = false;
|
private boolean color = false;
|
||||||
private int vertexLength = 3;
|
private boolean texture = false;
|
||||||
private int length = 0;
|
private boolean normals = false;
|
||||||
private boolean noColor = false;
|
private int normal;
|
||||||
public static ShapeRenderer instance = new ShapeRenderer();
|
private int vertexLength = 3;
|
||||||
|
private int length = 0;
|
||||||
|
private boolean noColor = false;
|
||||||
public final void end() {
|
public static ShapeRenderer instance = new ShapeRenderer();
|
||||||
if(this.vertices > 0) {
|
|
||||||
this.buffer.clear();
|
|
||||||
this.buffer.put(this.data, 0, this.length);
|
public final void end() {
|
||||||
this.buffer.flip();
|
if(this.vertices > 0) {
|
||||||
if(this.texture && this.color) {
|
this.buffer.clear();
|
||||||
GL11.glInterleavedArrays(10794, 0, this.buffer);
|
this.buffer.put(this.data, 0, this.length);
|
||||||
} else if(this.texture) {
|
this.buffer.flip();
|
||||||
GL11.glInterleavedArrays(10791, 0, this.buffer);
|
|
||||||
} else if(this.color) {
|
if (this.texture) {
|
||||||
GL11.glInterleavedArrays(10788, 0, this.buffer);
|
GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||||
} else {
|
}
|
||||||
GL11.glInterleavedArrays(10785, 0, this.buffer);
|
|
||||||
}
|
if (this.color) {
|
||||||
|
GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
||||||
GL11.glEnableClientState('\u8074');
|
}
|
||||||
if(this.texture) {
|
|
||||||
GL11.glEnableClientState('\u8078');
|
if (this.normals) {
|
||||||
}
|
GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
||||||
|
}
|
||||||
if(this.color) {
|
|
||||||
GL11.glEnableClientState('\u8076');
|
GL11._wglDrawArrays(7, 0, this.vertices);
|
||||||
}
|
|
||||||
|
if (this.texture) {
|
||||||
GL11.glDrawArrays(7, 0, this.vertices);
|
GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||||
GL11.glDisableClientState('\u8074');
|
}
|
||||||
if(this.texture) {
|
|
||||||
GL11.glDisableClientState('\u8078');
|
if (this.color) {
|
||||||
}
|
GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
|
||||||
|
}
|
||||||
if(this.color) {
|
|
||||||
GL11.glDisableClientState('\u8076');
|
if (this.normals) {
|
||||||
}
|
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.clear();
|
|
||||||
}
|
this.clear();
|
||||||
|
}
|
||||||
private void clear() {
|
|
||||||
this.vertices = 0;
|
private void clear() {
|
||||||
this.buffer.clear();
|
this.vertices = 0;
|
||||||
this.length = 0;
|
this.buffer.clear();
|
||||||
}
|
this.length = 0;
|
||||||
|
}
|
||||||
public final void begin() {
|
|
||||||
this.clear();
|
public final void begin() {
|
||||||
this.color = false;
|
this.clear();
|
||||||
this.texture = false;
|
this.normals = false;
|
||||||
this.noColor = false;
|
this.color = false;
|
||||||
}
|
this.texture = false;
|
||||||
|
this.noColor = false;
|
||||||
public final void color(float var1, float var2, float var3) {
|
}
|
||||||
if(!this.noColor) {
|
|
||||||
if(!this.color) {
|
public final void color(float var1, float var2, float var3) {
|
||||||
this.vertexLength += 3;
|
if(!this.noColor) {
|
||||||
}
|
if(!this.color) {
|
||||||
|
this.vertexLength += 3;
|
||||||
this.color = true;
|
}
|
||||||
this.r = var1;
|
|
||||||
this.g = var2;
|
this.color = true;
|
||||||
this.b = var3;
|
this.r = var1;
|
||||||
}
|
this.g = var2;
|
||||||
}
|
this.b = var3;
|
||||||
|
}
|
||||||
public final void vertexUV(float var1, float var2, float var3, float var4, float var5) {
|
}
|
||||||
if(!this.texture) {
|
|
||||||
this.vertexLength += 2;
|
public final void vertexUV(float var1, float var2, float var3, float var4, float var5) {
|
||||||
}
|
if(!this.texture) {
|
||||||
|
this.vertexLength += 2;
|
||||||
this.texture = true;
|
}
|
||||||
this.u = var4;
|
|
||||||
this.v = var5;
|
this.texture = true;
|
||||||
this.vertex(var1, var2, var3);
|
this.u = var4;
|
||||||
}
|
this.v = var5;
|
||||||
|
this.vertex(var1, var2, var3);
|
||||||
public final void vertex(float var1, float var2, float var3) {
|
}
|
||||||
if(this.texture) {
|
|
||||||
this.data[this.length++] = this.u;
|
public final void vertex(float var1, float var2, float var3) {
|
||||||
this.data[this.length++] = this.v;
|
if(this.texture) {
|
||||||
}
|
this.data[this.length++] = this.u;
|
||||||
|
this.data[this.length++] = this.v;
|
||||||
if(this.color) {
|
}
|
||||||
this.data[this.length++] = this.r;
|
|
||||||
this.data[this.length++] = this.g;
|
if(this.color) {
|
||||||
this.data[this.length++] = this.b;
|
this.data[this.length++] = this.r;
|
||||||
}
|
this.data[this.length++] = this.g;
|
||||||
|
this.data[this.length++] = this.b;
|
||||||
this.data[this.length++] = var1;
|
}
|
||||||
this.data[this.length++] = var2;
|
|
||||||
this.data[this.length++] = var3;
|
if(this.normals) {
|
||||||
++this.vertices;
|
this.data[this.length++] = this.normal;
|
||||||
if(this.vertices % 4 == 0 && this.length >= 524288 - (this.vertexLength << 2)) {
|
}
|
||||||
this.end();
|
|
||||||
}
|
this.data[this.length++] = var1;
|
||||||
|
this.data[this.length++] = var2;
|
||||||
}
|
this.data[this.length++] = var3;
|
||||||
|
++this.vertices;
|
||||||
public final void color(int var1) {
|
if(this.vertices % 4 == 0 && this.length >= 524288 - (this.vertexLength << 2)) {
|
||||||
int var2 = var1 >> 16 & 255;
|
this.end();
|
||||||
int var3 = var1 >> 8 & 255;
|
}
|
||||||
var1 &= 255;
|
|
||||||
int var10001 = var2;
|
}
|
||||||
int var10002 = var3;
|
|
||||||
var3 = var1;
|
public final void color(int var1) {
|
||||||
var2 = var10002;
|
int var2 = var1 >> 16 & 255;
|
||||||
var1 = var10001;
|
int var3 = var1 >> 8 & 255;
|
||||||
byte var7 = (byte)var1;
|
var1 &= 255;
|
||||||
byte var4 = (byte)var2;
|
int var10001 = var2;
|
||||||
byte var8 = (byte)var3;
|
int var10002 = var3;
|
||||||
byte var6 = var4;
|
var3 = var1;
|
||||||
byte var5 = var7;
|
var2 = var10002;
|
||||||
if(!this.noColor) {
|
var1 = var10001;
|
||||||
if(!this.color) {
|
byte var7 = (byte)var1;
|
||||||
this.vertexLength += 3;
|
byte var4 = (byte)var2;
|
||||||
}
|
byte var8 = (byte)var3;
|
||||||
|
byte var6 = var4;
|
||||||
this.color = true;
|
byte var5 = var7;
|
||||||
this.r = (float)(var5 & 255) / 255.0F;
|
if(!this.noColor) {
|
||||||
this.g = (float)(var6 & 255) / 255.0F;
|
if(!this.color) {
|
||||||
this.b = (float)(var8 & 255) / 255.0F;
|
this.vertexLength += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
this.color = true;
|
||||||
|
this.r = (float)(var5 & 255) / 255.0F;
|
||||||
public final void noColor() {
|
this.g = (float)(var6 & 255) / 255.0F;
|
||||||
this.noColor = true;
|
this.b = (float)(var8 & 255) / 255.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void normal(float var1, float var2, float var3) {
|
}
|
||||||
GL11.glNormal3f(var1, var2, var3);
|
|
||||||
}
|
public final void noColor() {
|
||||||
|
this.noColor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user