Hi, I posted a similar question but I get no answer so I simplify it in this forum. Please do not mark as duplicate. If I have a 2d float array like (float[][] transformMatrix = new float[][]) I want to send it to the shader to be used with the inPosition:
void main()
{
gl_Position = transformation * in_Position;
}
I tried like this:
glUseProgram(programID);
for(int i = 0; i < 4;i++) {
for(int j = 0;j<4;j++) {
matrix44Buffer.put(transformation.mat[i][j]);
}
}
glUniformMatrix4fv(MatrixLocation, false, matrix44Buffer);
matrix44Buffer.flip();
glUseProgram(0);
It isn't working. How to send the float[][] to the shader? All the websites that I found were using JOML or lwjgl 2 which has its own matrices.
I succeed I need to convert the 2D position/rotation/scale/projection array(float[][]) into a 1D float array(float[])
Ex(I have this scale matrix as a float[][]):
2 0 0 0
0 2 0 0
0 0 2 0
0 0 0 1
I needed to put in a float[] like that:
2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1
and then send the float[] directly to GLSL without any float buffer like that:
glUseProgram(programID);
int MatrixID = glGetUniformLocation(programID, "theMatrix");
glUniformMatrix4fv(MatrixID, false, translationArray);
glUseProgram(0);