So I can’t seem to fix my rendering code in lwjgl. I’ve narrowed the problem down to how I’m loading a Matrix4f into glUniformMatrix4() as a FloatBuffer.
Long story short, I know:
public FloatBuffer toBuffer(Matrix4f mat){
FloatBuffer matrixBuffer = BufferUtils.createFloatBuffer(16);
matrixBuffer.clear();
mat.store(matrixBuffer);
matrixBuffer.flip();
return matrixBuffer;
}
Does not return a buffer that renders properly (black screen).
And I know that:
private final static FloatBuffer direct = BufferUtils.createFloatBuffer(16);
public FloatBuffer toBuffer() {
direct.clear();
direct.put(matrix); // matrix is a float[16]
direct.flip();
return direct;
}
works.
Why? What is different here? Is there a more convenient way to upload a Matrix4f to lwjgl than my first snippet or an easy way to convert a Marix4f to a float[]?
I’m really stumped. Thanks.