I would avoid creating classes to handle lower level stuff like vectors and matrix's use array's of record's as they are opengl friendly and well managed by fpc. never use multi dimensional array's as they will not be a single chunck of memory. for lower level stuff stick to procedural comands that dont require you to create a class ever time you want to use a command.
Code:
TFlt4 = packed record
case Integer of
0:(X,Y,Z,W:Single);
1:(S:Array [0..3] of Single);
2:(R,G,B,A:Single);
3:(X1,Y1,X2,Y2:Single);
end;
TArrFlt4 = array of TFlt4;
TFlt3 = packed record
case Integer of
0:(X,Y,Z:Single);
1:(S:Array[0..2] of Single);
2:(R,G,B:Single);
end;
TArrFlt3 = array of TFlt3;
Points:TArrFlt3;
SetLength(Points,10);
Points[0]:=VecFlt3(1,1,1);
Points[1]:=Points[0];
Points[1].X+=0.5;
Points[1].S[2]:=2;// same as Points[1].Y but is index able Points[1].S[i]:=10;
Colors:TArrFlt3;
SetLength(Colors,10);
Colors[i].R:=0.25;
Colors[i].B:=0.125;
Colors[i].G:=0;
Colors[2]:=VecFlt3(0.5,1.0,0);
Color:TFlt4;
Color.R:=0.75;
Color.B:=0.25;
Color.G:=0;
Color.A:=1.0;
Color:=VecFlt4(1,0.75,1,1);
Colors[2]:=Color;
as I have said these record type arrays are opengl friendy you can pass them like this @Points[0]
Bookmarks