Sign in to follow this  
phb5000

[MDX] Newbie - Shaders

Recommended Posts

phb5000    122
effect = Effect.FromFile(device, @"simple.fx", null, null, ShaderFlags.None, null); Results in: InvalidDataException was unhandled Is there something wrong with the shader or is there something wrong with the loading code?

Share this post


Link to post
Share on other sites
robydx    225
should be an error in the shader.
there is an override that return a string with shader error in last position. You can use it.
If you want to see some sample come on my website

www.robydx.135.it

I have a lot of sample with shader effect (some in VB and some in C#).

It's in italian but there is source code, just go in directX9 session, than in Direct3D (go in managed .net 1.1, I've just began to write tutorial for .net 2.0)

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Try compiling the shader outside of your code using fxc.exe - it's a command line tool that will tell you if the shader has any errors. I don't know how the MDX code handles it, but you can (in code) extract the same buffer of errors should you wish to have your program output it to a logfile (etc..)

hth
Jack

Share this post


Link to post
Share on other sites
remigius    1172
You can fetch the compiler errors from the effect loading function in MDX like this:

[source lang=csharp]
Effect effect = null;
string errors = string.Empty;

try
{
string file = "yourFileName.fx";
// you can of course also use other overloads with the "out string errors" parameter
Effect effect = Effect.FromFile(device, file, new Macro[0], null, "", ShaderFlags.None, effectPool, out errors);
System.Diagnostics.Debug.WriteLine("Effect '" + file + "' loaded succesfully");
if (errors != string.Empty) System.Diagnostics.Debug.WriteLine(errors);
}
catch (Exception exp)
{
System.Diagnostics.Debug.WriteLine(exp);
if (errors != string.Empty) System.Diagnostics.Debug.WriteLine(errors);
}






Hope this helps :)

Share this post


Link to post
Share on other sites
Demirug    884
Quote:
Original post by jollyjeffers
I don't know how the MDX code handles it, but you can (in code) extract the same buffer of errors should you wish to have your program output it to a logfile (etc..)

hth
Jack


MDX can return the errors as optional out string parameter (compilationErrors).

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