Renderer: Fix critical bug that black screen Minecraft

This commit is contained in:
tom lee
2021-12-15 00:04:04 +08:00
parent 483ecf2e4d
commit b5665a59c0
3 changed files with 30 additions and 18 deletions
@@ -226,11 +226,9 @@ public class LodRenderer
//===================//
profiler.push("LOD draw setup");
// Get or setup the gl proxy and the needed objects
if (!GLProxy.hasInstance() && isSetupComplete)
ClientApi.LOGGER.warn("GLProxy has not yet been inited yet renderer state is enabled!");
int currentProgram = GL20.glGetInteger(GL20.GL_CURRENT_PROGRAM);
// Setup LodRenderProgram and the LightmapTexture if it has not yet been done
if (!isSetupComplete) setup();
@@ -250,7 +248,6 @@ public class LodRenderer
GL15.glEnable(GL15.GL_BLEND);
// get MC's shader program
int currentProgram = GL20.glGetInteger(GL20.GL_CURRENT_PROGRAM);
// Get the matrixs for rendering
Mat4f modelViewMatrix = translateModelViewMatrix(mcModelViewMatrix, partialTicks);
@@ -317,7 +314,7 @@ public class LodRenderer
shaderProgram.bind();
shaderProgram.bindVertexBuffer(bufferId);
GL30.glDrawArrays(GL30.GL_TRIANGLES, 0, vbos[x][z][i].vertexCount);
shaderProgram.unbindVertexBuffer();
//shaderProgram.unbindVertexBuffer();
}
@@ -332,11 +329,11 @@ public class LodRenderer
// if this cleanup isn't done MC will crash
// when trying to render its own terrain
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
lightmapTexture.unbind();
shaderProgram.unbind();
lightmapTexture.free();
profiler.popPush("LOD cleanup");
GL15.glPolygonMode(GL15.GL_FRONT_AND_BACK, GL15.GL_FILL);
@@ -19,6 +19,7 @@
package com.seibel.lod.core.render.objects;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
@@ -38,34 +39,34 @@ public abstract class VertexAttribute {
this.byteSize = byteSize;
}
public static VertexPointer addFloatPointer(boolean normalized) {
return new VertexPointer(1, GL20.GL_FLOAT, normalized, 4);
return new VertexPointer(1, GL15.GL_FLOAT, normalized, 4);
}
public static VertexPointer addVec2Pointer(boolean normalized) {
return new VertexPointer(2, GL20.GL_FLOAT, normalized, 8);
return new VertexPointer(2, GL15.GL_FLOAT, normalized, 8);
}
public static VertexPointer addVec3Pointer(boolean normalized) {
return new VertexPointer(3, GL20.GL_FLOAT, normalized, 12);
return new VertexPointer(3, GL15.GL_FLOAT, normalized, 12);
}
public static VertexPointer addVec4Pointer(boolean normalized) {
return new VertexPointer(1, GL20.GL_FLOAT, normalized, 16);
return new VertexPointer(1, GL15.GL_FLOAT, normalized, 16);
}
public static VertexPointer addUnsignedBytePointer(boolean normalized) {
return new VertexPointer(1, GL20.GL_UNSIGNED_BYTE, normalized, 1);
return new VertexPointer(1, GL15.GL_UNSIGNED_BYTE, normalized, 1);
}
public static VertexPointer addUnsignedBytesPointer(int elementCount, boolean normalized) {
return new VertexPointer(elementCount, GL20.GL_UNSIGNED_BYTE, normalized, elementCount);
return new VertexPointer(elementCount, GL15.GL_UNSIGNED_BYTE, normalized, elementCount);
}
public static VertexPointer addIntPointer(boolean normalized) {
return new VertexPointer(1, GL20.GL_INT, normalized, 4);
return new VertexPointer(1, GL15.GL_INT, normalized, 4);
}
public static VertexPointer addIvec2Pointer(boolean normalized) {
return new VertexPointer(2, GL20.GL_INT, normalized, 8);
return new VertexPointer(2, GL15.GL_INT, normalized, 8);
}
public static VertexPointer addIvec3Pointer(boolean normalized) {
return new VertexPointer(3, GL20.GL_INT, normalized, 12);
return new VertexPointer(3, GL15.GL_INT, normalized, 12);
}
public static VertexPointer addIvec4Pointer(boolean normalized) {
return new VertexPointer(4, GL20.GL_INT, normalized, 16);
return new VertexPointer(4, GL15.GL_INT, normalized, 16);
}
}
@@ -128,6 +128,20 @@ public final class VertexAttributePreGL43 extends VertexAttribute {
" does not match the provided expected stride size " + expectedStrideSize + "!");
strideSize = currentOffset;
ClientApi.LOGGER.info("Vertex Attribute (pre GL43) completed.");
// Debug logging
ClientApi.LOGGER.info("Vertex Attribute Debug Data:");
for (int i=0; i< pointers.length; i++) {
VertexPointer pointer = pointers[i];
if (pointer==null) {
ClientApi.LOGGER.info(i + ": Null");
continue;
}
ClientApi.LOGGER.info(i + ": "+pointer.elementCount+", "+
pointer.glType+", "+pointer.normalized+", "+strideSize+", "+pointersOffset[i]);
}
}
}