/// <summary>
 /// Adds a new material renderer to the VideoDriver, based on a high level shading language. Currently only HLSL/D3D9 and GLSL/OpenGL is supported. 
 /// </summary>
 /// <param name="vsprogram">String containing the source of the vertex shader program. This can be "" if no vertex program should be used. </param>
 /// <param name="ventrypoint">Name of the function of the vertexShaderProgram </param>
 /// <param name="vsCompileTarget">Vertex shader version where the high level shader should be compiled to. </param>
 /// <param name="psprogram">String containing the source of the pixel shader program. This can be "" if no pixel shader should be used.</param>
 /// <param name="psEntryPoint">Entry name of the function of the pixelShaderEntryPointName </param>
 /// <param name="psCompileTarget">Pixel shader version where the high level shader should be compiled to. </param>
 /// <param name="callback">Delegate in which you can set the needed vertex and pixel shader program constants.</param>
 /// <param name="baseMat">Base material which renderstates will be used to shade the material. </param>
 /// <param name="userData">An user data int. This int can be set to any value and will be set as parameter in the callback method when calling OnSetConstants(). In this way it is easily possible to use the same delegate method for multiple materials and distinguish between them during the call.</param>
 /// <returns>The Material to use with SetMaterial (with a C-style explicit cast). -1 if failed</returns>
 public int AddHighLevelShaderMaterial(string vsprogram, string ventrypoint, VertexShaderType vsCompileTarget, string psprogram, string psEntryPoint, PixelShaderType psCompileTarget, OnShaderConstantSetDelegate callback, MaterialType baseMat, int userData)
 {
     //WORKAROUND : Bug found by DeusXL, little workaround I don't like at all but needed !
     string vsfilename = System.IO.Path.GetTempFileName();
     StreamWriter vssw = new StreamWriter(vsfilename, false);
     string psfilename = System.IO.Path.GetTempFileName();
     StreamWriter pssw = new StreamWriter(psfilename, false);
     vssw.WriteLine(vsprogram);
     pssw.WriteLine(psprogram);
     vssw.Close();
     pssw.Close();
     int ret = AddHighLevelShaderMaterialFromFiles(vsfilename, ventrypoint, vsCompileTarget, psfilename, psEntryPoint, psCompileTarget, callback, baseMat, userData);
     try { File.Delete(vsfilename); File.Delete(psfilename); }
     catch (Exception) { }
     return ret;
 }
 /// <summary>
 /// Adds a new material renderer to the VideoDriver, using pixel and/or vertex shaders to render geometry. Note that it is a good idea to call VideoDriver.QueryFeature() before to check if the VideoDriver supports the vertex and/or pixel shader version your are using.
 /// </summary>
 /// <param name="vsprogram">String containing the source of the vertex shader program. This can be "" (empty string) if no vertex program should be used. For DX8 programs, the will always input registers look like this: v0: position, v1: normal, v2: color, v3: texture cooridnates, v4: texture coordinates 2 if available. For DX9 programs, you can manually set the registers using the dcl_ statements.</param>
 /// <param name="psprogram">String containing the source of the pixel shader program. This can be "" (empty string) if you don't want to use a pixel shader. </param>
 /// <param name="callback">Delegate in which you can set the needed vertex and pixel shader program constants.</param>
 /// <param name="baseMat">Base material which renderstates will be used to shade the material. </param>
 /// <param name="userData">An user data int. This int can be set to any value and will be set as parameter in the callback method when calling OnSetConstants(). In this way it is easily possible to use the same callback method for multiple materials and distinguish between them during the call. </param>
 /// <returns>The Material to use with SetMaterial (with a C-style explicit cast). -1 if failed</returns>
 public int AddShaderMaterial(string vsprogram, string psprogram, OnShaderConstantSetDelegate callback, MaterialType baseMat, int userData)
 {
     return GPU_AddShaderMaterial(_raw, vsprogram, psprogram, new ShaderConstantCallback(callback).OnNativeShaderConstant, baseMat, userData);
 }
 /// <summary>
 /// Adds a new material renderer to the VideoDriver, based on a high level shading language. Currently only HLSL/D3D9 and GLSL/OpenGL is supported. 
 /// </summary>
 /// <param name="program">String containing the path to the vertex shader program. This can be "" (empty string) if no vertex program should be used. </param>
 /// <param name="ventrypoint">Name of the function of the vertexShaderProgram </param>
 /// <param name="vsCompileTarget">Vertex shader version where the high level shader should be compiled to. </param>
 /// <param name="pixelShaderProgram">String containing the path to the pixel shader program. This can be "" (empty string) if no pixel shader should be used.</param>
 /// <param name="psEntryPoint">Entry name of the function of the pixelShaderEntryPointName </param>
 /// <param name="psCompileTarget">Pixel shader version where the high level shader should be compiled to. </param>
 /// <param name="callback">Delegate in which you can set the needed vertex and pixel shader program constants.</param>
 /// <param name="baseMat">Base material which renderstates will be used to shade the material. </param>
 /// <param name="userData">An user data int. This int can be set to any value and will be set as parameter in the callback method when calling OnSetConstants(). In this way it is easily possible to use the same delegate method for multiple materials and distinguish between them during the call.</param>
 /// <returns>The Material to use with SetMaterial (with a C-style explicit cast). -1 if failed</returns>
 public int AddHighLevelShaderMaterialFromFiles(string program, string ventrypoint, VertexShaderType vsCompileTarget, string pixelShaderProgram, string psEntryPoint, PixelShaderType psCompileTarget, OnShaderConstantSetDelegate callback, MaterialType baseMat, int userData)
 {
     return GPU_AddHighLevelShaderMaterialFromFiles(_raw, program, ventrypoint, vsCompileTarget, pixelShaderProgram, psEntryPoint, psCompileTarget, new ShaderConstantCallback(callback).OnNativeShaderConstant, baseMat, userData);
 }
 public ShaderConstantCallback(OnShaderConstantSetDelegate del)
 {
     scclist.Add(this);
     _deleg = del;
     OnNativeShaderConstant = Callback;
 }