/// <summary> /// Compiles an effect from a string. /// </summary> /// <param name="device">The device.</param> /// <param name="sourceData">The source data.</param> /// <param name="preprocessorDefines">The preprocessor defines.</param> /// <param name="includeFile">The include file.</param> /// <param name="skipConstants">The skip constants.</param> /// <param name="flags">The flags.</param> /// <param name="pool">The pool.</param> /// <returns> /// An <see cref="Effect"/> /// </returns> /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged> public static Effect FromString(Device device, string sourceData, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool) { Effect effect = null; Blob blobForErrors = null; var buffer = Marshal.StringToHGlobalAnsi(sourceData); try { D3DX9.CreateEffectEx( device, buffer, sourceData.Length, PrepareMacros(preprocessorDefines), IncludeShadow.ToIntPtr(includeFile), skipConstants, (int)flags, pool, out effect, out blobForErrors); } catch (SharpDXException ex) { if (blobForErrors != null) throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors)); throw; } finally { Marshal.FreeHGlobal(buffer); } return effect; }
/// <summary> /// Compiles an effect from a memory buffer. /// </summary> /// <param name="device">The device.</param> /// <param name="memory">The buffer.</param> /// <param name="preprocessorDefines">The preprocessor defines.</param> /// <param name="includeFile">The include file.</param> /// <param name="skipConstants">The skip constants.</param> /// <param name="flags">The flags.</param> /// <param name="pool">The pool.</param> /// <returns>An <see cref="Effect"/></returns> /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged> public static Effect FromMemory(Device device, byte[] memory, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool) { unsafe { Effect effect = null; Blob blobForErrors = null; try { fixed (void* pData = memory) D3DX9.CreateEffectEx( device, (IntPtr)pData, memory.Length, PrepareMacros(preprocessorDefines), IncludeShadow.ToIntPtr(includeFile), skipConstants, (int)flags, pool, out effect, out blobForErrors); } catch (SharpDXException ex) { if (blobForErrors != null) throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors)); throw; } return effect; } }
/// <summary> /// Compiles an effect from a stream. /// </summary> /// <param name="device">The device.</param> /// <param name="stream">The stream.</param> /// <param name="preprocessorDefines">The preprocessor defines.</param> /// <param name="includeFile">The include file.</param> /// <param name="skipConstants">The skip constants.</param> /// <param name="flags">The flags.</param> /// <param name="pool">The pool.</param> /// <returns>An <see cref="Effect"/></returns> /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged> public static Effect FromStream(Device device, Stream stream, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool) { unsafe { Effect effect = null; Blob blobForErrors = null; try { if (stream is DataStream) { D3DX9.CreateEffectEx( device, ((DataStream)stream).PositionPointer, (int)(stream.Length - stream.Position), PrepareMacros(preprocessorDefines), IncludeShadow.ToIntPtr(includeFile), skipConstants, (int)flags, pool, out effect, out blobForErrors); } else { var data = Utilities.ReadStream(stream); fixed (void* pData = data) D3DX9.CreateEffectEx( device, (IntPtr)pData, data.Length, PrepareMacros(preprocessorDefines), IncludeShadow.ToIntPtr(includeFile), skipConstants, (int)flags, pool, out effect, out blobForErrors); } stream.Position = stream.Length; } catch (SharpDXException ex) { if (blobForErrors != null) throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors)); throw; } return effect; } }
/// <summary> /// Compiles an effect from a file. /// </summary> /// <param name="device">The device.</param> /// <param name="fileName">Name of the file.</param> /// <param name="preprocessorDefines">The preprocessor defines.</param> /// <param name="includeFile">The include file.</param> /// <param name="skipConstants">The skip constants.</param> /// <param name="flags">The flags.</param> /// <param name="pool">The pool.</param> /// <returns> /// An <see cref="Effect"/> /// </returns> /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged> public static Effect FromFile(Device device, string fileName, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool) { return FromString(device, File.ReadAllText(fileName), preprocessorDefines, includeFile, skipConstants, flags, pool); }
/// <summary> /// Compiles an effect from a string. /// </summary> /// <param name="device">The device.</param> /// <param name="sourceData">The source data.</param> /// <param name="preprocessorDefines">The preprocessor defines.</param> /// <param name="includeFile">The include file.</param> /// <param name="skipConstants">The skip constants.</param> /// <param name="flags">The flags.</param> /// <param name="pool">The pool.</param> /// <returns> /// An <see cref="Effect"/> /// </returns> /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged> public static Effect FromString(Device device, string sourceData, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool) { Effect effect = null; Blob blobForErrors = null; var buffer = Marshal.StringToHGlobalAnsi(sourceData); try { D3DX9.CreateEffectEx( device, buffer, sourceData.Length, PrepareMacros(preprocessorDefines), IncludeShadow.ToIntPtr(includeFile), skipConstants, (int)flags, pool, out effect, out blobForErrors); } catch (SharpDXException ex) { if (blobForErrors != null) { throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors)); } throw; } finally { Marshal.FreeHGlobal(buffer); } return(effect); }
/// <summary> /// Compiles an effect from a stream. /// </summary> /// <param name="device">The device.</param> /// <param name="stream">The stream.</param> /// <param name="preprocessorDefines">The preprocessor defines.</param> /// <param name="includeFile">The include file.</param> /// <param name="skipConstants">The skip constants.</param> /// <param name="flags">The flags.</param> /// <param name="pool">The pool.</param> /// <returns>An <see cref="Effect"/></returns> /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged> public static Effect FromStream(Device device, Stream stream, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool) { unsafe { Effect effect = null; Blob blobForErrors = null; try { if (stream is DataStream) { D3DX9.CreateEffectEx( device, ((DataStream)stream).PositionPointer, (int)(stream.Length - stream.Position), PrepareMacros(preprocessorDefines), IncludeShadow.ToIntPtr(includeFile), skipConstants, (int)flags, pool, out effect, out blobForErrors); } else { var data = Utilities.ReadStream(stream); fixed(void *pData = data) D3DX9.CreateEffectEx( device, (IntPtr)pData, data.Length, PrepareMacros(preprocessorDefines), IncludeShadow.ToIntPtr(includeFile), skipConstants, (int)flags, pool, out effect, out blobForErrors); } stream.Position = stream.Length; } catch (SharpDXException ex) { if (blobForErrors != null) { throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors)); } throw; } return(effect); } }
/// <summary> /// Compiles an effect from a memory buffer. /// </summary> /// <param name="device">The device.</param> /// <param name="memory">The buffer.</param> /// <param name="preprocessorDefines">The preprocessor defines.</param> /// <param name="includeFile">The include file.</param> /// <param name="skipConstants">The skip constants.</param> /// <param name="flags">The flags.</param> /// <param name="pool">The pool.</param> /// <returns>An <see cref="Effect"/></returns> /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged> public static Effect FromMemory(Device device, byte[] memory, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool) { unsafe { Effect effect = null; Blob blobForErrors = null; try { fixed(void *pData = memory) D3DX9.CreateEffectEx( device, (IntPtr)pData, memory.Length, PrepareMacros(preprocessorDefines), IncludeShadow.ToIntPtr(includeFile), skipConstants, (int)flags, pool, out effect, out blobForErrors); } catch (SharpDXException ex) { if (blobForErrors != null) { throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors)); } throw; } return(effect); } }
/// <summary> /// Compiles an effect from a file. /// </summary> /// <param name="device">The device.</param> /// <param name="fileName">Name of the file.</param> /// <param name="preprocessorDefines">The preprocessor defines.</param> /// <param name="includeFile">The include file.</param> /// <param name="skipConstants">The skip constants.</param> /// <param name="flags">The flags.</param> /// <param name="pool">The pool.</param> /// <returns> /// An <see cref="Effect"/> /// </returns> /// <unmanaged>HRESULT D3DXCreateEffectEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataLen,[In, Buffer] const D3DXMACRO* pDefines,[In] ID3DXInclude* pInclude,[In] const char* pSkipConstants,[In] unsigned int Flags,[In] ID3DXEffectPool* pPool,[In] ID3DXEffect** ppEffect,[In] ID3DXBuffer** ppCompilationErrors)</unmanaged> public static Effect FromFile(Device device, string fileName, Macro[] preprocessorDefines, Include includeFile, string skipConstants, ShaderFlags flags, EffectPool pool) { return(FromString(device, File.ReadAllText(fileName), preprocessorDefines, includeFile, skipConstants, flags, pool)); }