[MDX] Newbie - Shaders

Started by
3 comments, last by Demirug 18 years, 1 month ago
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?
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)

http://www.notjustcode.it

DirectX tutorial

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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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 :)
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
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).

This topic is closed to new replies.

Advertisement