2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
24 #include "Enums11.h"
\r
25 #include "Resource11.h"
\r
26 #include "ImageLoadInformation11.h"
\r
30 ref class DataRectangle;
\r
32 namespace Direct3D11
\r
35 ref class DeviceContext;
\r
36 value class Texture2DDescription;
\r
39 /// Represents a two-dimensional texture.
\r
41 /// <unmanaged>ID3D11Texture2D</unmanaged>
\r
42 public ref class Texture2D : public Resource
\r
44 COMOBJECT(ID3D11Texture2D, Texture2D);
\r
47 static ID3D11Texture2D* Build( SlimDX::Direct3D11::Device^ device, Texture2DDescription description, D3D11_SUBRESOURCE_DATA* data );
\r
51 /// Gets the texture description.
\r
53 property Texture2DDescription Description
\r
55 Texture2DDescription get();
\r
59 /// Initializes a new instance of the <see cref="Texture2D"/> class.
\r
61 /// <param name="device">The device with which to associate the texture.</param>
\r
62 /// <param name="description">The description of the texture.</param>
\r
63 Texture2D( SlimDX::Direct3D11::Device^ device, Texture2DDescription description );
\r
66 /// Initializes a new instance of the <see cref="Texture2D"/> class.
\r
68 /// <param name="device">The device with which to associate the texture.</param>
\r
69 /// <param name="description">The description of the texture.</param>
\r
70 /// <param name="data">The initial texture data.</param>
\r
71 Texture2D( SlimDX::Direct3D11::Device^ device, Texture2DDescription description, DataRectangle^ data );
\r
74 /// Initializes a new instance of the <see cref="Texture2D"/> class.
\r
76 /// <param name="device">The device with which to associate the texture.</param>
\r
77 /// <param name="description">The description of the texture.</param>
\r
78 /// <param name="data">An array of initial texture data for each subresource.</param>
\r
79 Texture2D( SlimDX::Direct3D11::Device^ device, Texture2DDescription description, array<DataRectangle^>^ data );
\r
82 /// Loads a texture from an image file.
\r
84 /// <param name="device">The device used to load the texture.</param>
\r
85 /// <param name="fileName">Path to the file on disk.</param>
\r
86 /// <returns>The loaded texture object.</returns>
\r
87 static Texture2D^ FromFile( SlimDX::Direct3D11::Device^ device, System::String^ fileName );
\r
90 /// Loads a texture from an image file.
\r
92 /// <param name="device">The device used to load the texture.</param>
\r
93 /// <param name="fileName">Path to the file on disk.</param>
\r
94 /// <param name="loadInfo">Specifies information used to load the texture.</param>
\r
95 /// <returns>The loaded texture object.</returns>
\r
96 static Texture2D^ FromFile( SlimDX::Direct3D11::Device^ device, System::String^ fileName, ImageLoadInformation loadInfo );
\r
99 /// Loads a texture from an image in memory.
\r
101 /// <param name="device">The device used to load the texture.</param>
\r
102 /// <param name="memory">Array of memory containing the image data to load.</param>
\r
103 /// <returns>The loaded texture object.</returns>
\r
104 static Texture2D^ FromMemory( SlimDX::Direct3D11::Device^ device, array<System::Byte>^ memory );
\r
107 /// Loads a texture from an image in memory.
\r
109 /// <param name="device">The device used to load the texture.</param>
\r
110 /// <param name="memory">Array of memory containing the image data to load.</param>
\r
111 /// <param name="loadInfo">Specifies information used to load the texture.</param>
\r
112 /// <returns>The loaded texture object.</returns>
\r
113 static Texture2D^ FromMemory( SlimDX::Direct3D11::Device^ device, array<System::Byte>^ memory, ImageLoadInformation loadInfo );
\r
116 /// Loads a texture from a stream of data.
\r
118 /// <param name="device">The device used to load the texture.</param>
\r
119 /// <param name="stream">A stream containing the image data to load.</param>
\r
120 /// <param name="sizeInBytes">Size of the image to load.</param>
\r
121 /// <returns>The loaded texture object.</returns>
\r
122 static Texture2D^ FromStream( SlimDX::Direct3D11::Device^ device, System::IO::Stream^ stream, int sizeInBytes );
\r
125 /// Loads a texture from a stream of data.
\r
127 /// <param name="device">The device used to load the texture.</param>
\r
128 /// <param name="stream">A stream containing the image data to load.</param>
\r
129 /// <param name="sizeInBytes">Size of the image to load.</param>
\r
130 /// <param name="loadInfo">Specifies information used to load the texture.</param>
\r
131 /// <returns>The loaded texture object.</returns>
\r
132 static Texture2D^ FromStream( SlimDX::Direct3D11::Device^ device, System::IO::Stream^ stream, int sizeInBytes, ImageLoadInformation loadInfo );
\r
135 /// Saves a texture to file.
\r
137 /// <param name="context">The device used to save the texture.</param>
\r
138 /// <param name="texture">The texture to save.</param>
\r
139 /// <param name="format">The format the texture will be saved as.</param>
\r
140 /// <param name="fileName">Name of the destination output file where the texture will be saved.</param>
\r
141 /// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
\r
142 static Result ToFile( DeviceContext^ context, Texture2D^ texture, ImageFileFormat format, System::String^ fileName );
\r
145 /// Saves a texture to a stream.
\r
147 /// <param name="context">The device used to save the texture.</param>
\r
148 /// <param name="texture">The texture to save.</param>
\r
149 /// <param name="format">The format the texture will be saved as.</param>
\r
150 /// <param name="stream">Destination memory stream where the image will be saved.</param>
\r
151 /// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
\r
152 static Result ToStream( DeviceContext^ context, Texture2D^ texture, ImageFileFormat format, System::IO::Stream^ stream );
\r
155 /// Converts a height map into a normal map. The (x,y,z) components of each normal are mapped to the (r,g,b) channels of the output texture.
\r
157 /// <param name="context">The device used to create the normal map.</param>
\r
158 /// <param name="source">The source height map texture.</param>
\r
159 /// <param name="destination">The destination texture.</param>
\r
160 /// <param name="flags">One or more flags that control generation of normal maps.</param>
\r
161 /// <param name="channel">One or more flag specifying the source of height information.</param>
\r
162 /// <param name="amplitude">Constant value multiplier that increases (or decreases) the values in the normal map. Higher values usually make bumps more visible, lower values usually make bumps less visible.</param>
\r
163 /// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
\r
164 static Result ComputeNormalMap(DeviceContext^ context, Texture2D^ source, Texture2D^ destination, NormalMapFlags flags, Channel channel, float amplitude);
\r