proliferate opengl error checking
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
05c51896e0
commit
9292e74221
@ -152,66 +152,104 @@ public class HomogenousInstancedArray {
|
|||||||
//"opengl matrix attribute"
|
//"opengl matrix attribute"
|
||||||
//https://learnopengl.com/code_viewer_gh.php?code=src/4.advanced_opengl/10.3.asteroids_instanced/asteroids_instanced.cpp
|
//https://learnopengl.com/code_viewer_gh.php?code=src/4.advanced_opengl/10.3.asteroids_instanced/asteroids_instanced.cpp
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//enable attributes
|
//enable attributes
|
||||||
GL45.glEnableVertexAttribArray(matrixAttributeIndices[0]);
|
GL45.glEnableVertexAttribArray(matrixAttributeIndices[0]);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glEnableVertexAttribArray(matrixAttributeIndices[1]);
|
GL45.glEnableVertexAttribArray(matrixAttributeIndices[1]);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glEnableVertexAttribArray(matrixAttributeIndices[2]);
|
GL45.glEnableVertexAttribArray(matrixAttributeIndices[2]);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glEnableVertexAttribArray(matrixAttributeIndices[3]);
|
GL45.glEnableVertexAttribArray(matrixAttributeIndices[3]);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//update attribute to point to buffer at correct offset + stride
|
//update attribute to point to buffer at correct offset + stride
|
||||||
GL45.glVertexAttribPointer(matrixAttributeIndices[0], 4, GL45.GL_FLOAT, false, 64, 0 * 4);
|
GL45.glVertexAttribPointer(matrixAttributeIndices[0], 4, GL45.GL_FLOAT, false, 64, 0 * 4);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribPointer(matrixAttributeIndices[1], 4, GL45.GL_FLOAT, false, 64, 4 * 4);
|
GL45.glVertexAttribPointer(matrixAttributeIndices[1], 4, GL45.GL_FLOAT, false, 64, 4 * 4);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribPointer(matrixAttributeIndices[2], 4, GL45.GL_FLOAT, false, 64, 4 * 8);
|
GL45.glVertexAttribPointer(matrixAttributeIndices[2], 4, GL45.GL_FLOAT, false, 64, 4 * 8);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribPointer(matrixAttributeIndices[3], 4, GL45.GL_FLOAT, false, 64, 4 * 12);
|
GL45.glVertexAttribPointer(matrixAttributeIndices[3], 4, GL45.GL_FLOAT, false, 64, 4 * 12);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//bind buffer
|
//bind buffer
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//tell opengl to send a new value from buffer for each instance (instead of whole buffer for every instance)
|
//tell opengl to send a new value from buffer for each instance (instead of whole buffer for every instance)
|
||||||
GL45.glVertexAttribDivisor(matrixAttributeIndices[0], 1);
|
GL45.glVertexAttribDivisor(matrixAttributeIndices[0], 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribDivisor(matrixAttributeIndices[1], 1);
|
GL45.glVertexAttribDivisor(matrixAttributeIndices[1], 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribDivisor(matrixAttributeIndices[2], 1);
|
GL45.glVertexAttribDivisor(matrixAttributeIndices[2], 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribDivisor(matrixAttributeIndices[3], 1);
|
GL45.glVertexAttribDivisor(matrixAttributeIndices[3], 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} else if(type == HomogenousBufferTypes.MAT4D){
|
} else if(type == HomogenousBufferTypes.MAT4D){
|
||||||
//https://solhsa.com/instancing.html
|
//https://solhsa.com/instancing.html
|
||||||
//https://stackoverflow.com/questions/17355051/using-a-matrix-as-vertex-attribute-in-opengl3-core-profile
|
//https://stackoverflow.com/questions/17355051/using-a-matrix-as-vertex-attribute-in-opengl3-core-profile
|
||||||
//"opengl matrix attribute"
|
//"opengl matrix attribute"
|
||||||
//https://learnopengl.com/code_viewer_gh.php?code=src/4.advanced_opengl/10.3.asteroids_instanced/asteroids_instanced.cpp
|
//https://learnopengl.com/code_viewer_gh.php?code=src/4.advanced_opengl/10.3.asteroids_instanced/asteroids_instanced.cpp
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//enable attributes
|
//enable attributes
|
||||||
GL45.glEnableVertexAttribArray(matrixAttributeIndices[0]);
|
GL45.glEnableVertexAttribArray(matrixAttributeIndices[0]);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glEnableVertexAttribArray(matrixAttributeIndices[1]);
|
GL45.glEnableVertexAttribArray(matrixAttributeIndices[1]);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glEnableVertexAttribArray(matrixAttributeIndices[2]);
|
GL45.glEnableVertexAttribArray(matrixAttributeIndices[2]);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glEnableVertexAttribArray(matrixAttributeIndices[3]);
|
GL45.glEnableVertexAttribArray(matrixAttributeIndices[3]);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//update attribute to point to buffer at correct offset + stride
|
//update attribute to point to buffer at correct offset + stride
|
||||||
GL45.glVertexAttribPointer(matrixAttributeIndices[0], 4, GL45.GL_FLOAT, false, 64, 0 * 4);
|
GL45.glVertexAttribPointer(matrixAttributeIndices[0], 4, GL45.GL_FLOAT, false, 64, 0 * 4);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribPointer(matrixAttributeIndices[1], 4, GL45.GL_FLOAT, false, 64, 4 * 4);
|
GL45.glVertexAttribPointer(matrixAttributeIndices[1], 4, GL45.GL_FLOAT, false, 64, 4 * 4);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribPointer(matrixAttributeIndices[2], 4, GL45.GL_FLOAT, false, 64, 4 * 8);
|
GL45.glVertexAttribPointer(matrixAttributeIndices[2], 4, GL45.GL_FLOAT, false, 64, 4 * 8);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribPointer(matrixAttributeIndices[3], 4, GL45.GL_FLOAT, false, 64, 4 * 12);
|
GL45.glVertexAttribPointer(matrixAttributeIndices[3], 4, GL45.GL_FLOAT, false, 64, 4 * 12);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//bind buffer
|
//bind buffer
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//tell opengl to send a new value from buffer for each instance (instead of whole buffer for every instance)
|
//tell opengl to send a new value from buffer for each instance (instead of whole buffer for every instance)
|
||||||
GL45.glVertexAttribDivisor(matrixAttributeIndices[0], 1);
|
GL45.glVertexAttribDivisor(matrixAttributeIndices[0], 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribDivisor(matrixAttributeIndices[1], 1);
|
GL45.glVertexAttribDivisor(matrixAttributeIndices[1], 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribDivisor(matrixAttributeIndices[2], 1);
|
GL45.glVertexAttribDivisor(matrixAttributeIndices[2], 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
GL45.glVertexAttribDivisor(matrixAttributeIndices[3], 1);
|
GL45.glVertexAttribDivisor(matrixAttributeIndices[3], 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} else if(type == HomogenousBufferTypes.FLOAT){
|
} else if(type == HomogenousBufferTypes.FLOAT){
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//enable attributes
|
//enable attributes
|
||||||
GL45.glEnableVertexAttribArray(attributeIndex);
|
GL45.glEnableVertexAttribArray(attributeIndex);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//update attribute to point to buffer at correct offset + stride
|
//update attribute to point to buffer at correct offset + stride
|
||||||
GL45.glVertexAttribPointer(attributeIndex, 1, GL45.GL_FLOAT, false, 0, 0);
|
GL45.glVertexAttribPointer(attributeIndex, 1, GL45.GL_FLOAT, false, 0, 0);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//bind buffer
|
//bind buffer
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//tell opengl to send a new value from buffer for each instance (instead of whole buffer for every instance)
|
//tell opengl to send a new value from buffer for each instance (instead of whole buffer for every instance)
|
||||||
GL45.glVertexAttribDivisor(attributeIndex, 1);
|
GL45.glVertexAttribDivisor(attributeIndex, 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} else if(type == HomogenousBufferTypes.VEC3F){
|
} else if(type == HomogenousBufferTypes.VEC3F){
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//enable attributes
|
//enable attributes
|
||||||
GL45.glEnableVertexAttribArray(attributeIndex);
|
GL45.glEnableVertexAttribArray(attributeIndex);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//update attribute to point to buffer at correct offset + stride
|
//update attribute to point to buffer at correct offset + stride
|
||||||
GL45.glVertexAttribPointer(attributeIndex, 3, GL45.GL_FLOAT, false, 0, 0);
|
GL45.glVertexAttribPointer(attributeIndex, 3, GL45.GL_FLOAT, false, 0, 0);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//bind buffer
|
//bind buffer
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
//tell opengl to send a new value from buffer for each instance (instead of whole buffer for every instance)
|
//tell opengl to send a new value from buffer for each instance (instead of whole buffer for every instance)
|
||||||
GL45.glVertexAttribDivisor(attributeIndex, 1);
|
GL45.glVertexAttribDivisor(attributeIndex, 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} else {
|
} else {
|
||||||
LoggerInterface.loggerRenderer.ERROR("Unsupported operation", new Exception());
|
LoggerInterface.loggerRenderer.ERROR("Unsupported operation", new Exception());
|
||||||
}
|
}
|
||||||
@ -226,45 +264,56 @@ public class HomogenousInstancedArray {
|
|||||||
public void updateBuffer(Object object, int startIndex){
|
public void updateBuffer(Object object, int startIndex){
|
||||||
//bind the buffer
|
//bind the buffer
|
||||||
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
switch(type){
|
switch(type){
|
||||||
case VEC3F: {
|
case VEC3F: {
|
||||||
FloatBuffer buffer = (FloatBuffer)object;
|
FloatBuffer buffer = (FloatBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} break;
|
} break;
|
||||||
case VEC3D: {
|
case VEC3D: {
|
||||||
DoubleBuffer buffer = (DoubleBuffer)object;
|
DoubleBuffer buffer = (DoubleBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} break;
|
} break;
|
||||||
case VEC4F: {
|
case VEC4F: {
|
||||||
FloatBuffer buffer = (FloatBuffer)object;
|
FloatBuffer buffer = (FloatBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} break;
|
} break;
|
||||||
case VEC4D: {
|
case VEC4D: {
|
||||||
DoubleBuffer buffer = (DoubleBuffer)object;
|
DoubleBuffer buffer = (DoubleBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} break;
|
} break;
|
||||||
case DOUBLE: {
|
case DOUBLE: {
|
||||||
DoubleBuffer buffer = (DoubleBuffer)object;
|
DoubleBuffer buffer = (DoubleBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} break;
|
} break;
|
||||||
case FLOAT: {
|
case FLOAT: {
|
||||||
FloatBuffer buffer = (FloatBuffer)object;
|
FloatBuffer buffer = (FloatBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} break;
|
} break;
|
||||||
case INT: {
|
case INT: {
|
||||||
IntBuffer buffer = (IntBuffer)object;
|
IntBuffer buffer = (IntBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
GL45.glNamedBufferSubData(bufferPointer,startIndex,buffer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} break;
|
} break;
|
||||||
case MAT4F: {
|
case MAT4F: {
|
||||||
FloatBuffer buffer = (FloatBuffer)object;
|
FloatBuffer buffer = (FloatBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer, startIndex, buffer);
|
GL45.glNamedBufferSubData(bufferPointer, startIndex, buffer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} break;
|
} break;
|
||||||
case MAT4D: {
|
case MAT4D: {
|
||||||
FloatBuffer buffer = (FloatBuffer)object;
|
FloatBuffer buffer = (FloatBuffer)object;
|
||||||
GL45.glNamedBufferSubData(bufferPointer, startIndex, buffer);
|
GL45.glNamedBufferSubData(bufferPointer, startIndex, buffer);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
//unbind the buffer
|
//unbind the buffer
|
||||||
GL33.glBindBuffer(GL45.GL_ARRAY_BUFFER, 0);
|
GL33.glBindBuffer(GL45.GL_ARRAY_BUFFER, 0);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -309,14 +309,17 @@ public class Mesh {
|
|||||||
if(currentUniformRaw instanceof Matrix4f){
|
if(currentUniformRaw instanceof Matrix4f){
|
||||||
Matrix4f currentUniform = (Matrix4f)currentUniformRaw;
|
Matrix4f currentUniform = (Matrix4f)currentUniformRaw;
|
||||||
glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), key), false, currentUniform.get(new float[16]));
|
glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), key), false, currentUniform.get(new float[16]));
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
if(currentUniformRaw instanceof Vector3f){
|
if(currentUniformRaw instanceof Vector3f){
|
||||||
Vector3f currentUniform = (Vector3f)currentUniformRaw;
|
Vector3f currentUniform = (Vector3f)currentUniformRaw;
|
||||||
glUniform3fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), key), currentUniform.get(BufferUtils.createFloatBuffer(3)));
|
glUniform3fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), key), currentUniform.get(BufferUtils.createFloatBuffer(3)));
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
if(currentUniformRaw instanceof Integer){
|
if(currentUniformRaw instanceof Integer){
|
||||||
int currentInform = (Integer)currentUniformRaw;
|
int currentInform = (Integer)currentUniformRaw;
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), key), currentInform);
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), key), currentInform);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,6 +350,7 @@ public class Mesh {
|
|||||||
|
|
||||||
//bind vao off the rip
|
//bind vao off the rip
|
||||||
glBindVertexArray(vertexArrayObject);
|
glBindVertexArray(vertexArrayObject);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
|
|
||||||
if(renderPipelineState.getUseMeshShader()){
|
if(renderPipelineState.getUseMeshShader()){
|
||||||
ShaderProgram selectedProgram = null;
|
ShaderProgram selectedProgram = null;
|
||||||
@ -409,6 +413,7 @@ public class Mesh {
|
|||||||
texture.bind(openGLState,5+i);
|
texture.bind(openGLState,5+i);
|
||||||
}
|
}
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), textureMask.getUniformNames().get(i)),5+i);
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), textureMask.getUniformNames().get(i)),5+i);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
} else if(textureMask.getTexturePaths() != null){
|
} else if(textureMask.getTexturePaths() != null){
|
||||||
@ -428,7 +433,9 @@ public class Mesh {
|
|||||||
|
|
||||||
if(renderPipelineState.getUseShadowMap()){
|
if(renderPipelineState.getUseShadowMap()){
|
||||||
openGLState.glActiveTexture(GL_TEXTURE3);
|
openGLState.glActiveTexture(GL_TEXTURE3);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
openGLState.glBindTexture(GL_TEXTURE_2D, RenderingEngine.lightBufferDepthTexture.getTexturePointer());
|
openGLState.glBindTexture(GL_TEXTURE_2D, RenderingEngine.lightBufferDepthTexture.getTexturePointer());
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "shadowMap"), 3);
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "shadowMap"), 3);
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
@ -440,7 +447,9 @@ public class Mesh {
|
|||||||
//
|
//
|
||||||
if(bones != null && !bones.isEmpty()){
|
if(bones != null && !bones.isEmpty()){
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasBones"), 1);
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasBones"), 1);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "numBones"), bones.size());
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "numBones"), bones.size());
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
Iterator<String> boneIterator = boneIdList.iterator();
|
Iterator<String> boneIterator = boneIdList.iterator();
|
||||||
// float bufferarray[] = new float[16];
|
// float bufferarray[] = new float[16];
|
||||||
int incrementer = 0;
|
int incrementer = 0;
|
||||||
@ -457,20 +466,24 @@ public class Mesh {
|
|||||||
// System.out.println(currentMat);
|
// System.out.println(currentMat);
|
||||||
// }
|
// }
|
||||||
openGLState.getActiveShader().setUniform(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), currentUniform), currentMat);
|
openGLState.getActiveShader().setUniform(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), currentUniform), currentMat);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
// GL45.glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), currentUniform), false, bufferarray);
|
// GL45.glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), currentUniform), false, bufferarray);
|
||||||
} else {
|
} else {
|
||||||
// System.out.println("Bonename: " + boneName);
|
// System.out.println("Bonename: " + boneName);
|
||||||
// System.exit(1);
|
// System.exit(1);
|
||||||
openGLState.getActiveShader().setUniform(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), currentUniform), new float[16]);
|
openGLState.getActiveShader().setUniform(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), currentUniform), new float[16]);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
// GL45.glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), currentUniform), false, new float[16]);
|
// GL45.glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), currentUniform), false, new float[16]);
|
||||||
}
|
}
|
||||||
incrementer++;
|
incrementer++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasBones"), 0);
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasBones"), 0);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasBones"), 0);
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "hasBones"), 0);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
|
|
||||||
@ -479,14 +492,23 @@ public class Mesh {
|
|||||||
//buffer model/view/proj matrices
|
//buffer model/view/proj matrices
|
||||||
try(MemoryStack stack = MemoryStack.stackPush()){
|
try(MemoryStack stack = MemoryStack.stackPush()){
|
||||||
GL45.glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexModelLoc, false, parent.getModelMatrix().get(new float[16]));
|
GL45.glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexModelLoc, false, parent.getModelMatrix().get(new float[16]));
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexViewLoc, false, Globals.viewMatrix.get(new float[16]));
|
glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexViewLoc, false, Globals.viewMatrix.get(new float[16]));
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexProjectionLoc, false, Globals.projectionMatrix.get(new float[16]));
|
glUniformMatrix4fv(openGLState.getActiveShader().shaderVertexProjectionLoc, false, Globals.projectionMatrix.get(new float[16]));
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glUniform3fv(openGLState.getActiveShader().shaderVertexViewPosLoc, CameraEntityUtils.getCameraEye(Globals.playerCamera).get(stack.floats(3)));
|
glUniform3fv(openGLState.getActiveShader().shaderVertexViewPosLoc, CameraEntityUtils.getCameraEye(Globals.playerCamera).get(stack.floats(3)));
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
Vector3f worldPos = new Vector3f((float)parent.getWorldPos().x,(float)parent.getWorldPos().y,(float)parent.getWorldPos().z);
|
Vector3f worldPos = new Vector3f((float)parent.getWorldPos().x,(float)parent.getWorldPos().y,(float)parent.getWorldPos().z);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glUniform3fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "modelWorldPos"), worldPos.get(stack.mallocFloat(3)));
|
glUniform3fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "modelWorldPos"), worldPos.get(stack.mallocFloat(3)));
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "frame"), (int)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "frame"), (int)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
glUniform1f(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "time"), (float)Globals.timekeeper.getCurrentRendererTime());
|
glUniform1f(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "time"), (float)Globals.timekeeper.getCurrentRendererTime());
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
@ -510,15 +532,18 @@ public class Mesh {
|
|||||||
|
|
||||||
if(renderPipelineState.getInstanced()){
|
if(renderPipelineState.getInstanced()){
|
||||||
GL45.glDrawElementsInstanced(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0, renderPipelineState.getInstanceCount());
|
GL45.glDrawElementsInstanced(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0, renderPipelineState.getInstanceCount());
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} else {
|
} else {
|
||||||
if(useElementArray){
|
if(useElementArray){
|
||||||
GL11.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0);
|
GL11.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
} else {
|
} else {
|
||||||
GL11.glDrawArrays(GL_TRIANGLES, 0, elementCount);
|
GL11.glDrawArrays(GL_TRIANGLES, 0, elementCount);
|
||||||
}
|
|
||||||
}
|
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
|
}
|
||||||
|
}
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -777,10 +777,12 @@ public class ShaderProgram {
|
|||||||
*/
|
*/
|
||||||
public void setUniform(OpenGLState openGLState, String uniformName, Object value){
|
public void setUniform(OpenGLState openGLState, String uniformName, Object value){
|
||||||
int uniformLocation = glGetUniformLocation(this.getShaderId(), uniformName);
|
int uniformLocation = glGetUniformLocation(this.getShaderId(), uniformName);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
if(uniformLocation == INVALID_UNIFORM_NAME){
|
if(uniformLocation == INVALID_UNIFORM_NAME){
|
||||||
LoggerInterface.loggerRenderer.DEBUG_LOOP("Searched for uniform in a shader that does not contain it. Uniform name: \"" + uniformName + "\"");
|
LoggerInterface.loggerRenderer.DEBUG_LOOP("Searched for uniform in a shader that does not contain it. Uniform name: \"" + uniformName + "\"");
|
||||||
} else {
|
} else {
|
||||||
setUniform(uniformLocation, value);
|
setUniform(uniformLocation, value);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -304,6 +304,7 @@ public class Texture {
|
|||||||
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to bind texture object that has texturepointer of 0"));
|
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to bind texture object that has texturepointer of 0"));
|
||||||
}
|
}
|
||||||
openGLState.glBindTextureUnit(GL_TEXTURE0 + attrib_val,this.texturePointer,GL_TEXTURE_2D);
|
openGLState.glBindTextureUnit(GL_TEXTURE0 + attrib_val,this.texturePointer,GL_TEXTURE_2D);
|
||||||
|
Globals.renderingEngine.checkError();
|
||||||
// openGLState.glActiveTexture(GL_TEXTURE0 + attrib_val);
|
// openGLState.glActiveTexture(GL_TEXTURE0 + attrib_val);
|
||||||
// openGLState.glBindTexture(GL_TEXTURE_2D, texturePointer);
|
// openGLState.glBindTexture(GL_TEXTURE_2D, texturePointer);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user