/// <summary>	
 /// Create a shader-resource view from a file.	
 /// </summary>	
 /// <param name="device">A reference to the device (see <see cref="SharpDX.Direct3D10.Device"/>) that will use the resource. </param>
 /// <param name="fileName">Name of the file that contains the shader-resource view.</param>
 /// <param name="loadInformation">Identifies the characteristics of a texture (see <see cref="SharpDX.Direct3D10.ImageLoadInformation"/>) when the data processor is created. </param>
 /// <returns>Returns a reference to the shader-resource view (see <see cref="SharpDX.Direct3D10.ShaderResourceView"/>). </returns>
 /// <unmanaged>HRESULT D3DX10CreateShaderResourceViewFromFileW([None] ID3D10Device* pDevice,[None] const wchar_t* pSrcFile,[In, Optional] D3DX10_IMAGE_LOAD_INFO* pLoadInfo,[None] ID3DX10ThreadPump* pPump,[None] ID3D10ShaderResourceView** ppShaderResourceView,[None] HRESULT* pHResult)</unmanaged>
 public static ShaderResourceView FromFile(Device device, string fileName, ImageLoadInformation loadInformation)
 {
     ShaderResourceView temp;
     Result hResult;
     D3DX10.CreateShaderResourceViewFromFile(device, fileName, loadInformation, IntPtr.Zero, out temp, out hResult);
     return temp;
 }
        /// <summary>
        /// Create a shader-resource view from a file.
        /// </summary>
        /// <param name="device">A reference to the device (see <see cref="SharpDX.Direct3D10.Device"/>) that will use the resource. </param>
        /// <param name="fileName">Name of the file that contains the shader-resource view.</param>
        /// <param name="loadInformation">Identifies the characteristics of a texture (see <see cref="SharpDX.Direct3D10.ImageLoadInformation"/>) when the data processor is created. </param>
        /// <returns>Returns a reference to the shader-resource view (see <see cref="SharpDX.Direct3D10.ShaderResourceView"/>). </returns>
        /// <unmanaged>HRESULT D3DX10CreateShaderResourceViewFromFileW([None] ID3D10Device* pDevice,[None] const wchar_t* pSrcFile,[In, Optional] D3DX10_IMAGE_LOAD_INFO* pLoadInfo,[None] ID3DX10ThreadPump* pPump,[None] ID3D10ShaderResourceView** ppShaderResourceView,[None] HRESULT* pHResult)</unmanaged>
        public static ShaderResourceView FromFile(Device device, string fileName, ImageLoadInformation loadInformation)
        {
            ShaderResourceView temp;
            Result             hResult;

            D3DX10.CreateShaderResourceViewFromFile(device, fileName, loadInformation, IntPtr.Zero, out temp, out hResult);
            return(temp);
        }
Beispiel #3
0
        /// <summary>
        ///   Loads a texture from an image file.
        /// </summary>
        /// <param name = "device">The device used to load the texture.</param>
        /// <param name = "fileName">Path to the file on disk.</param>
        /// <param name = "loadInfo">Specifies information used to load the texture.</param>
        /// <returns>The loaded texture object.</returns>
        public static T FromFile <T>(Device device, string fileName, ImageLoadInformation loadInfo) where T : Resource
        {
            IntPtr temp;
            Result resultOut;

            D3DX10.CreateTextureFromFile(device, fileName, loadInfo, IntPtr.Zero, out temp, out resultOut);
            // TODO test resultOut?
            return(FromPointer <T>(temp));
        }
Beispiel #4
0
        /// <summary>
        ///   Loads a texture from an image file.
        /// </summary>
        /// <param name = "device">The device used to load the texture.</param>
        /// <param name = "fileName">Path to the file on disk.</param>
        /// <param name = "loadInfo">Specifies information used to load the texture.</param>
        /// <returns>The loaded texture object.</returns>
        public static T FromFile <T>(Device device, string fileName, ImageLoadInformation loadInfo) where T : Resource
        {
            System.Diagnostics.Debug.Assert(typeof(T) == typeof(Texture1D) || typeof(T) == typeof(Texture2D) ||
                                            typeof(T) == typeof(Texture3D));

            IntPtr temp;
            Result resultOut;

            D3DX10.CreateTextureFromFile(device, fileName, loadInfo, IntPtr.Zero, out temp, out resultOut);
            // TODO test resultOut?
            return(FromPointer <T>(temp));
        }
        /// <summary>
        /// Create a shader-resource view from a file in memory.
        /// </summary>
        /// <param name="device">A reference to the device (see <see cref="SharpDX.Direct3D10.Device"/>) that will use the resource. </param>
        /// <param name="memory">Pointer to a memory location that contains the shader-resource view. </param>
        /// <param name="loadInformation">Identifies the characteristics of a texture (see <see cref="SharpDX.Direct3D10.ImageLoadInformation"/>) when the data processor is created. </param>
        /// <returns>Returns a reference to the shader-resource view (see <see cref="SharpDX.Direct3D10.ShaderResourceView"/>). </returns>
        /// <unmanaged>HRESULT D3DX10CreateShaderResourceViewFromMemory([None] ID3D10Device* pDevice,[None] const void* pSrcData,[None] SIZE_T SrcDataSize,[In, Optional] D3DX10_IMAGE_LOAD_INFO* pLoadInfo,[None] ID3DX10ThreadPump* pPump,[None] ID3D10ShaderResourceView** ppShaderResourceView,[None] HRESULT* pHResult)</unmanaged>
        public static ShaderResourceView FromMemory(Device device, byte[] memory, ImageLoadInformation loadInformation)
        {
            unsafe
            {
                ShaderResourceView temp;
                Result             hResult;

                fixed(void *pMemory = &memory[0])
                D3DX10.CreateShaderResourceViewFromMemory(device, new IntPtr(pMemory), memory.Length, loadInformation, IntPtr.Zero, out temp, out hResult);

                return(temp);
            }
        }
Beispiel #6
0
        /// <summary>
        ///   Loads a texture from an image in memory.
        /// </summary>
        /// <param name = "device">The device used to load the texture.</param>
        /// <param name = "memory">Array of memory containing the image data to load.</param>
        /// <param name = "loadInfo">Specifies information used to load the texture.</param>
        /// <returns>The loaded texture object.</returns>
        public static T FromMemory <T>(Device device, byte[] memory, ImageLoadInformation loadInfo) where T : Resource
        {
            unsafe
            {
                IntPtr temp;
                Result resultOut;

                fixed(void *pBuffer = &memory[0])
                D3DX10.CreateTextureFromMemory(device, (IntPtr)pBuffer, memory.Length, loadInfo, IntPtr.Zero,
                                               out temp, out resultOut);

                // TODO test resultOut?
                return(FromPointer <T>(temp));
            }
        }
Beispiel #7
0
        /// <summary>
        ///   Loads a texture from an image in memory.
        /// </summary>
        /// <param name = "device">The device used to load the texture.</param>
        /// <param name = "memory">Array of memory containing the image data to load.</param>
        /// <param name = "loadInfo">Specifies information used to load the texture.</param>
        /// <returns>The loaded texture object.</returns>
        public static T FromMemory <T>(Device device, byte[] memory, ImageLoadInformation loadInfo) where T : Resource
        {
            System.Diagnostics.Debug.Assert(typeof(T) == typeof(Texture1D) || typeof(T) == typeof(Texture2D) ||
                                            typeof(T) == typeof(Texture3D));

            unsafe
            {
                System.Diagnostics.Debug.Assert(memory != null);
                System.Diagnostics.Debug.Assert(memory.Length > 0);
                IntPtr temp;
                Result resultOut;

                fixed(void *pBuffer = &memory[0])
                D3DX10.CreateTextureFromMemory(device, (IntPtr)pBuffer, memory.Length, loadInfo, IntPtr.Zero,
                                               out temp, out resultOut);

                // TODO test resultOut?
                return(FromPointer <T>(temp));
            }
        }
 /// <summary>	
 /// Create a shader-resource view from a file in a stream..	
 /// </summary>	
 /// <param name="device">A reference to the device (see <see cref="SharpDX.Direct3D10.Device"/>) that will use the resource. </param>
 /// <param name="stream">Pointer to the file in memory that contains the shader-resource view. </param>
 /// <param name="sizeInBytes">Size of the file to read from the stream</param>
 /// <param name="loadInformation">Identifies the characteristics of a texture (see <see cref="SharpDX.Direct3D10.ImageLoadInformation"/>) when the data processor is created. </param>
 /// <returns>Returns a reference to the shader-resource view (see <see cref="SharpDX.Direct3D10.ShaderResourceView"/>). </returns>
 /// <unmanaged>HRESULT D3DX10CreateShaderResourceViewFromMemory([None] ID3D10Device* pDevice,[None] const void* pSrcData,[None] SIZE_T SrcDataSize,[In, Optional] D3DX10_IMAGE_LOAD_INFO* pLoadInfo,[None] ID3DX10ThreadPump* pPump,[None] ID3D10ShaderResourceView** ppShaderResourceView,[None] HRESULT* pHResult)</unmanaged>
 public static ShaderResourceView FromStream(Device device, Stream stream, int sizeInBytes, ImageLoadInformation loadInformation)
 {
     byte[] memory = Utilities.ReadStream(stream, ref sizeInBytes);
     return FromMemory(device, memory, loadInformation);
 }
 /// <summary>	
 /// Create a shader-resource view from a file in memory.	
 /// </summary>	
 /// <param name="device">A reference to the device (see <see cref="SharpDX.Direct3D10.Device"/>) that will use the resource. </param>
 /// <param name="memory">Pointer to a memory location that contains the shader-resource view. </param>
 /// <param name="loadInformation">Identifies the characteristics of a texture (see <see cref="SharpDX.Direct3D10.ImageLoadInformation"/>) when the data processor is created. </param>
 /// <returns>Returns a reference to the shader-resource view (see <see cref="SharpDX.Direct3D10.ShaderResourceView"/>). </returns>
 /// <unmanaged>HRESULT D3DX10CreateShaderResourceViewFromMemory([None] ID3D10Device* pDevice,[None] const void* pSrcData,[None] SIZE_T SrcDataSize,[In, Optional] D3DX10_IMAGE_LOAD_INFO* pLoadInfo,[None] ID3DX10ThreadPump* pPump,[None] ID3D10ShaderResourceView** ppShaderResourceView,[None] HRESULT* pHResult)</unmanaged>
 public static ShaderResourceView FromMemory(Device device, byte[] memory, ImageLoadInformation loadInformation)
 {
     unsafe
     {
         ShaderResourceView temp;
         Result hResult;
         fixed (void* pMemory = &memory[0])
             D3DX10.CreateShaderResourceViewFromMemory(device, new IntPtr(pMemory), memory.Length, loadInformation, IntPtr.Zero, out temp, out hResult);
         return temp;
     }
 }
Beispiel #10
0
 /// <summary>
 ///   Loads a texture from a stream of data.
 /// </summary>
 /// <param name = "device">The device used to load the texture.</param>
 /// <param name = "stream">A stream containing the image data to load.</param>
 /// <param name = "sizeInBytes">Size of the image to load.</param>
 /// <param name = "loadInfo">Specifies information used to load the texture.</param>
 /// <returns>The loaded texture object.</returns>
 public static T FromStream <T>(Device device, Stream stream, int sizeInBytes, ImageLoadInformation loadInfo)
     where T : Resource
 {
     byte[] buffer = Utilities.ReadStream(stream, ref sizeInBytes);
     return(FromMemory <T>(device, buffer, loadInfo));
 }
Beispiel #11
0
 /// <summary>
 /// Create a shader-resource view from a file in a stream..
 /// </summary>
 /// <param name="device">A reference to the device (see <see cref="SharpDX.Direct3D10.Device"/>) that will use the resource. </param>
 /// <param name="stream">Pointer to the file in memory that contains the shader-resource view. </param>
 /// <param name="sizeInBytes">Size of the file to read from the stream</param>
 /// <param name="loadInformation">Identifies the characteristics of a texture (see <see cref="SharpDX.Direct3D10.ImageLoadInformation"/>) when the data processor is created. </param>
 /// <returns>Returns a reference to the shader-resource view (see <see cref="SharpDX.Direct3D10.ShaderResourceView"/>). </returns>
 /// <unmanaged>HRESULT D3DX10CreateShaderResourceViewFromMemory([None] ID3D10Device* pDevice,[None] const void* pSrcData,[None] SIZE_T SrcDataSize,[In, Optional] D3DX10_IMAGE_LOAD_INFO* pLoadInfo,[None] ID3DX10ThreadPump* pPump,[None] ID3D10ShaderResourceView** ppShaderResourceView,[None] HRESULT* pHResult)</unmanaged>
 public static ShaderResourceView FromStream(Device device, Stream stream, int sizeInBytes, ImageLoadInformation loadInformation)
 {
     byte[] memory = Utilities.ReadStream(stream, ref sizeInBytes);
     return(FromMemory(device, memory, loadInformation));
 }