to use advanced records you must add this to your unit
{$modeswitch advancedrecords}
Lazarus doesn't really like advanced records too much mostly because it doesn't understand them but I haven't gotten any debuger errors.
TMatrix4 = packed record
Procedure Identity;
Procedure Projection(vFov,vRatio,vNear,vFar:Single);
Procedure Translation(vX,vY,vZ:Single);
Procedure RotateAxisX(vAngle:Single);
Procedure RotateAxisY(vAngle:Single);
Procedure RotateAxisZ(vAngle:Single);
Procedure Multiply(const vMatrix1,vMatrix2:TMatrix4);
public
case Integer of
0:(S:Array [0..15] of Single);
1:(D:Array [0..3,0..3] of Single);
2:(C:Array [0..3] of TVector4);
end;
this it what I have working at the moment.
TranMatrix.Translation( 0,-2,-10);
RotMatrix.RotateAxisY(45);
ProjMatrix.Multiply(RotMatrix,TranMatrix);
ViewMatrix.Projection(45,0.75,0,1000);
ProjMatrixLoc:=glGetUniformLocation(Shader.ProgramHandle,PChar('projMatrix'));
ViewMatrixLoc:=glGetUniformLocation(Shader.ProgramHandle,PChar('viewMatrix'));
Shader.Activate;
glUniformMatrix4fv(ProjMatrixLoc,1,false, @ProjMatrix.S[0]);
glUniformMatrix4fv(ViewMatrixLoc,1,false, @ViewMatrix.S[0]);
and this is what it looks like in action
notice the public keyword separating the comands from the fields there has to be a keyword to separate them or it won't compile
Matrix.C[0].XYZW(1,2,3,4);
Matrix.C[0].X:=2;
Matrix.D[vx,vx]:=1;
Matrix.S[15]:=10;
a few more examples to show you the different ways we can use this matrix