2 * Copyright (c) 2007-2010 SlimDX Group
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 #include "../ComObject.h"
25 #include "../DataRectangle.h"
28 #include "Resource10.h"
29 #include "ImageLoadInformation.h"
33 ref class DataRectangle;
38 value class Texture2DDescription;
40 public ref class Texture2D : public Resource
42 COMOBJECT(ID3D10Texture2D, Texture2D);
45 static ID3D10Texture2D* Build( SlimDX::Direct3D10::Device^ device, Texture2DDescription description, D3D10_SUBRESOURCE_DATA* data );
49 /// Gets the texture description.
51 property Texture2DDescription Description
53 Texture2DDescription get();
57 /// Initializes a new instance of the <see cref="Texture2D"/> class.
59 /// <param name="device">The device to associate the texture with.</param>
60 /// <param name="description">The description of the texture.</param>
61 Texture2D( SlimDX::Direct3D10::Device^ device, Texture2DDescription description );
64 /// Initializes a new instance of the <see cref="Texture2D"/> class.
66 /// <param name="device">The device to associate the texture with.</param>
67 /// <param name="description">The description of the texture.</param>
68 /// <param name="data">The initial texture data.</param>
69 Texture2D( SlimDX::Direct3D10::Device^ device, Texture2DDescription description, DataRectangle^ data );
72 /// Initializes a new instance of the <see cref="Texture2D"/> class.
74 /// <param name="device">The device to associate the texture with.</param>
75 /// <param name="description">The description of the texture.</param>
76 /// <param name="data">An array of initial texture data for each subresource.</param>
77 Texture2D( SlimDX::Direct3D10::Device^ device, Texture2DDescription description, array<DataRectangle^>^ data );
80 /// Maps the texture, providing CPU access to its contents.
82 /// <param name="subresource">The subresource to map.</param>
83 /// <param name="mode">The IO operations to enable on the CPU.</param>
84 /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param>
85 /// <returns>A data rectangle containing the mapped data. This data stream is invalidated
86 /// when the buffer is unmapped.</returns>
87 DataRectangle^ Map( int subresource, MapMode mode, MapFlags flags );
90 /// Unmaps the texture.
92 /// <param name="subresource">The subresource to unmap.</param>
93 void Unmap( int subresource );
95 static Texture2D^ FromFile( SlimDX::Direct3D10::Device^ device, System::String^ fileName );
96 static Texture2D^ FromFile( SlimDX::Direct3D10::Device^ device, System::String^ fileName, ImageLoadInformation loadInfo );
97 static Texture2D^ FromMemory( SlimDX::Direct3D10::Device^ device, array<System::Byte>^ memory );
98 static Texture2D^ FromMemory( SlimDX::Direct3D10::Device^ device, array<System::Byte>^ memory, ImageLoadInformation loadInfo );
99 static Texture2D^ FromStream( SlimDX::Direct3D10::Device^ device, System::IO::Stream^ stream, int sizeInBytes );
100 static Texture2D^ FromStream( SlimDX::Direct3D10::Device^ device, System::IO::Stream^ stream, int sizeInBytes, ImageLoadInformation loadInfo );
102 static Result ToFile( Texture2D^ texture, ImageFileFormat format, System::String^ fileName );
103 static Result ToStream( Texture2D^ texture, ImageFileFormat format, System::IO::Stream^ stream );
105 static Result ComputeNormalMap(Texture2D^ source, Texture2D^ destination, NormalMapFlags flags, Channel channel, float amplitude);