explicit error on setting uniform to unsupported type
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
fc4730c24a
commit
f6ac972aa7
@ -464,7 +464,7 @@ public class Mesh {
|
||||
} else {
|
||||
// System.out.println("Bonename: " + boneName);
|
||||
// System.exit(1);
|
||||
openGLState.getActiveShader().setUniform(openGLState, currentUniform, new float[16]);
|
||||
openGLState.getActiveShader().setUniform(openGLState, currentUniform, new Matrix4f());
|
||||
// GL45.glUniformMatrix4fv(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), currentUniform), false, new float[16]);
|
||||
}
|
||||
incrementer++;
|
||||
|
||||
@ -675,36 +675,33 @@ public class ShaderProgram {
|
||||
* @param value the value
|
||||
*/
|
||||
public void setUniform(OpenGLState openGLState, int uniformLocation, Object value){
|
||||
if(DISABLE_CACHING || !uniformMap.containsKey(uniformLocation) || !uniformMap.get(uniformLocation).equals(value)){
|
||||
if(
|
||||
DISABLE_CACHING ||
|
||||
!uniformMap.containsKey(uniformLocation) ||
|
||||
!uniformMap.get(uniformLocation).equals(value)
|
||||
){
|
||||
try(MemoryStack stack = MemoryStack.stackPush()){
|
||||
uniformMap.put(uniformLocation,value);
|
||||
if(value instanceof Matrix4f){
|
||||
Matrix4f currentUniform = (Matrix4f)value;
|
||||
GL40.glUniformMatrix4fv(uniformLocation, false, currentUniform.get(new float[16]));
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
if(value instanceof Matrix4d){
|
||||
} else if(value instanceof Matrix4d){
|
||||
Matrix4d currentUniform = (Matrix4d)value;
|
||||
GL40.glUniformMatrix4fv(uniformLocation, false, currentUniform.get(new float[16]));
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
if(value instanceof Vector3f){
|
||||
} else if(value instanceof Vector3f){
|
||||
Vector3f currentUniform = (Vector3f)value;
|
||||
GL40.glUniform3fv(uniformLocation, currentUniform.get(BufferUtils.createFloatBuffer(3)));
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
if(value instanceof Integer){
|
||||
} else if(value instanceof Integer){
|
||||
GL40.glUniform1i(uniformLocation, (Integer)value);
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
if(value instanceof Float){
|
||||
} else if(value instanceof Float){
|
||||
GL40.glUniform1f(uniformLocation, (Float)value);
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
if(value instanceof Vector3f){
|
||||
Vector3f vectorView = (Vector3f)value;
|
||||
GL40.glUniform3fv(uniformLocation, vectorView.get(stack.mallocFloat(3)));
|
||||
Globals.renderingEngine.checkError();
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Tried to set uniform with unsupported type!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user