Okay ! I found my problem As you said my FillCubeMap function was a method of my Form's class and that didn't work !

But now I've got another problem. I got an exception when the function is called, during the transfer of one of the parameters into a local variable.

I compared to C sources and ... I saw something strange ... In C, the function D3DXFillCubeTexture is called with a TD3DXFill3D function ... not a 2D. But here in delphi, it is called with a 2D ... Why ?

Just to give an idea of what I'm doing here is my code (oh by the way ! No need of cdecl)

[pascal]
procedure FillCubeMap(out pOut : TD3DXVector4; const pTexCoord : TD3DXVector2; const pTexelSize : TD3DXVector2; var pData);
var
tC : TD3DXVector2;
Begin

tC := pTexCoord; // Seems to crash here

D3DXVec2Normalize(tC, tC);

D3DXVec2Scale(tC, tC, 0.5);
tC := D3DXVec2Add(tC, D3DXVector2(0.5, 0.5));

pOut := D3DXVector4(tC.x, tC.y, 0.0, 1.0);

end;[/pascal]

And here the code for the creation :

[pascal]if Failed(Device.CreateCubeTexture(256, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, CubeMap, nil)) then
Begin
ShowMessage('The creation of the CubeMap failed');
dxReady := False;
exit;
end;

if Failed(D3DXFillCubeTexture(CubeMap, FillCubeMap, tmp)) then
Begin
ShowMessage('D3DXFillCubeTexture failed');
dxReady := False;
exit;
end;[/pascal]

Any idea of what makes the app crash ?

Another question, since we can't put "nil" in the 3rd parameter of the function, any type is good ? Or should I have something special ?

Thanks
bye
Avatar