Hello I've been trying to compile shaders with SlimDX and ShaderBytecode.CompileShader() but I always get the exception that says unexpected 'something' and that something is always the first character in the shader. I've also tried with different shader profiles as "vs_1_0", "vs_3_0" etc so I guess that's not the problem. I set the entry point to the name of the function, for my testing I put it as "vertexShaderEntry" am I supposed to specify parameters or something in that string in the CompileShader() call as well?
From what I've tried I believe there's something wrong with my byte array made from the string containing my whole shader code.
This is the code where I take the shaderData string, consisting of the full shader code, and turn it into a byte array. The string is taken from a multiline textbox control.
I can't seem to find any errors so I'd appreciate if anyone else finds any.
To get byte array from string just use Encoding class: byte[] sourceBytes = System.Text.Encoding.UTF8.GetBytes(sourceString);
And afaik ShaderBytecode.CompileShader can accept string as shader source - there is no need to convert it to byte array:
http://slimdx.mdxinfo.com/latestdocs/help/html/M_SlimDX_D3DCompiler_ShaderBytecode_Compile_2_f3570541.htm
To get byte array from string just use Encoding class: byte[] sourceBytes = System.Text.Encoding.UTF8.GetBytes(sourceString);
And afaik ShaderBytecode.CompileShader can accept string as shader source - there is no need to convert it to byte array: http://slimdx.mdxinf..._2_f3570541.htm
Oh man, so embarrassing to have missed that one. Thanks a ton, it works like a charm now!