Hey everyone.

I'm trying to make a little sample that uses *.fx files. Unfortunatly i cannot run the BasicHLSL sample from the SDK because D3D somehow keeps failing because of a non-zero reference count.

So i started writing a very simple effect file, which does nothing special:

//=====================================
// My first Effect file
//=====================================

//Variabeles
float4x4 g_mWorldViewProjection;
texture g_MeshTexture;


//structures
struct VS_OUTPUT
{
float4 Position : POSITION;
float2 TextureCoords: TEXCOORD1;
};

struct PS_OUTPUT
{
float4 Color : COLOR0;
};

//--------------------------------------------------------------------------------------
// Texture samplers
//--------------------------------------------------------------------------------------
sampler MeshTextureSampler =
sampler_state
{
Texture = <g_MeshTexture>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};


VS_OUTPUT VS_Function( float4 vPos : POSITION,
float2 vTexCoord0 : TEXCOORD0 )
{
VS_OUTPUT Output;

OutPut.Position = Mul( vPos, g_mWorldViewProjection );
OutPut.TextureCoords = vTexCoord0;
return Output;
}

PS_OUTPUT PS_Function(VS_OUTPUT in)
{
PS_OUTPUT Output;

Output.RGBColor = tex2D(MeshTextureSampler, In.TextureCoords);

Return Output;
}


//my first technique
Technique MyTechnique
{
Pass FirstPass
{
VertexShader = compile vs_2_0 VS_function();
PixelShader = compile ps_2_0 PS_function();
}
}
As far as i know, this should work.

But when i run this code:

[pascal]
HR := D3DXCreateEffectFromFile(g_pd3ddevice ,pChar(ExtractFilePath(ParamStr(0))+'effect.fx'),n il,nil,D3DXFX_NOT_CLONEABLE,nil,g_effect,nil);
if Failed(HR) then
begin
//report error....
Exit;
end;
[/pascal]

It returns E_FAIL, which is a weird DX error code.
I usually get something like D3DERR_INVALIDCALL.
The filepath passed to the function is correct.

The weird thing is that the debug runtimes don't report an error. :? :cry:
maybe i can debug it by using PIX but i don't know how it works yet.
I guess the problem has to do with the contents of the fx file, but i realy have no idea what could
be wrong. :?

Can someone help me to get this working. plz??

Thanx in advance.