unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TMyMatrix =
array[0..15]
of Single;
PMyMatrix = ^TMyMatrix;
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
procedure MultMatrix(x, y, z: Pointer);
stdcall;
external '
test.dll';
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
pa, pb, pc: PMyMatrix;
p1, p2, p3: Pointer;
i: Integer;
begin
GetMem(p1, SizeOf(TMyMatrix)+15);
pa:= PMyMatrix((Integer(p1)+$0F)
and $FFFFFFF0);
ZeroMemory(pa, SizeOf(TMyMatrix));
GetMem(p2, SizeOf(TMyMatrix)+15);
pb:= PMyMatrix((Integer(p2)+$0F)
and $FFFFFFF0);
ZeroMemory(pb, SizeOf(TMyMatrix));
GetMem(p3, SizeOf(TMyMatrix)+15);
pc:= PMyMatrix((Integer(p3)+$0F)
and $FFFFFFF0);
ZeroMemory(pc, SizeOf(TMyMatrix));
for i:=0
to 15
do pc^[i]:=0.0;
// pc is an empty matrix, pa, bb are
// arbitrary 4x4 Matrices
pa^[00]:= 1.0; pa^[01]:= 2.0; pa^[02]:= 3.0; pa^[03]:= 1.0;
pa^[04]:= 2.0; pa^[05]:= 3.0; pa^[06]:= 1.0; pa^[07]:= 2.0;
pa^[08]:= 3.0; pa^[09]:= 1.0; pa^[10]:= 2.0; pa^[11]:= 3.0;
pa^[12]:= 1.0; pa^[13]:= 2.0; pa^[14]:= 3.0; pa^[15]:= 1.0;
pb^[00]:= 3.0; pb^[01]:= 2.0; pb^[02]:= 1.0; pb^[03]:= 3.0;
pb^[04]:= 2.0; pb^[05]:= 1.0; pb^[06]:= 3.0; pb^[07]:= 2.0;
pb^[08]:= 1.0; pb^[09]:= 3.0; pb^[10]:= 2.0; pb^[11]:= 1.0;
pb^[12]:= 3.0; pb^[13]:= 2.0; pb^[14]:= 1.0; pb^[15]:= 3.0;
MultMatrix(pa, pb, pc);
//pc is the Result
FreeMem(p1);
FreeMem(p2);
FreeMem(p3);
end;
end.