• Advertisement
Sign in to follow this  

[MDX] Newbie - Shaders

This topic is 4369 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
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
Sign in to follow this  

  • Advertisement