Sign in to follow this  
sapman

C#.net Effect Class and Fx Files Error

Recommended Posts

sapman    100
Hi , I am using managed DirectX and C#.net , when i Run program , the program throws an error : " Error in Application..." and highlights below line :
effect = Effect.FromFile(dev, @"..\..\simple.fx", null, ShaderFlags.None, null);
and here is simple.fx :
// Shader output, position and diffuse color
struct VS_OUTPUT
{
    float4 pos  : POSITION;
    float4 diff : COLOR0;
};

// The world view and projection matrices
float4x4 WorldViewProj : WORLDVIEWPROJECTION;
float Time = 1.0f;

// Transform our coordinates into world space
VS_OUTPUT Transform(
    float4 Pos  : POSITION)
{
    // Declare our return variable
    VS_OUTPUT Out = (VS_OUTPUT)0;

    // Transform our position
    Out.pos = mul(Pos, WorldViewProj);
    // Set our color
    Out.diff.r = 1 - Time;
    Out.diff.b = Time * WorldViewProj[2].yz;
    Out.diff.ga = Time * WorldViewProj[0].xy;

    // Return
    return Out;
}
technique TransformDiffuse
{
    pass P0
    {
        CullMode = None;

        // shaders
        VertexShader = compile vs_1_1 Transform();
        PixelShader  = NULL;
    }
}

Share this post


Link to post
Share on other sites
sapman    100
okay , I have solve it myself ; and the error cause by this reason
that we should create are effect in our render function .
<in Timer.> or <form_paint>
.

Share this post


Link to post
Share on other sites
kiza    100
I still have the same problem and i don't see solution... can anybody help me? I use "Managed DirectX 9: graphics and game programming" by Tom Miller.
Btw, i would be very grateful if someone can give msn or skype contact to me. It will not be so much wasting of time, just to show me where the problem is when i stop at some point and i can't continue..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this