Share via


CubeTexture.CubeTexture(Device,Int32,Int32,Usage,Format,Pool) Constructor (Microsoft.DirectX.Direct3D)

How Do I...?

  • Create a Cube Texture

Initializes a new instance of the CubeTexture class.

Definition

Visual Basic Public Sub New( _
    ByVal device As Device, _
    ByVal edgeLength As Integer, _
    ByVal levels As Integer, _
    ByVal usage As Usage, _
    ByVal format As Format, _
    ByVal pool As Pool _
)
C# public CubeTexture(
    Device device,
    int edgeLength,
    int levels,
    Usage usage,
    Format format,
    Pool pool
);
C++ public:
 CubeTexture(
    Devicedevice,
    int edgeLength,
    int levels,
    Usage usage,
    Format format,
    Pool pool
);
JScript public function CubeTexture(
    device : Device,
    edgeLength : int,
    levels : int,
    usage : Usage,
    format : Format,
    pool : Pool
);

Parameters

device Microsoft.DirectX.Direct3D.Device
A Device object.
edgeLength System.Int32
Size of the edges of all top-level faces of the cube texture. The pixel dimensions of subsequent levels of each face are the truncated value of half of the previous level's pixel dimension (independently). Each dimension clamps at a size of 1 pixel. Thus, if the division by 2 results in 0, 1 is taken instead.
levels System.Int32
Number of levels in each face of the cube texture. If this value is 0, Microsoft Direct3D generates all cube texture sublevels down to 1x1 pixels for each face, for hardware that supports cube textures. To see the number of levels generated, check the BaseTexture.LevelCount property.
usage Microsoft.DirectX.Direct3D.Usage
Usage can be 0, which indicates no usage value. However, if usage is desired, use a combination of one or more Usage values. It is good practice to match the usage parameter in the CubeTexture constructor with the behavior flags in the Device constructor. See Remarks.
format Microsoft.DirectX.Direct3D.Format
Member of the Format enumerated type that describes the format of all levels in all faces of the cube texture.
pool Microsoft.DirectX.Direct3D.Pool
A Pool value that describes the memory class into which the cube texture should be placed.

Remarks

A mipmap is a collection of successively downsampled (mipmapped) surfaces. A cube texture created by CubeTexture is a collection of six textures (each mipmapped), one for each face. All faces must be present in the cube texture. Also, a cube map surface must be the same pixel size in all three dimensions (x, y, and z).

An application can discover support for the automatic generation of mipmaps in a particular format by calling Manager.CheckDeviceFormat with Usage.AutoGenerateMipMap. If Manager.CheckDeviceFormat returns false, this constructor succeeds, but it creates a one-level texture.

How Do I...?

Create a Cube Texture

This example demonstrates how to create a cube texture.

A cube texture is created after the hardware is checked to ensure that cube textures are supported. The new cube texture has an edge length of 16 pixels, and no Usage value. Provided the hardware supports mipmap cube textures, all cube texture sublevels down to 1x1 pixels for each face are automatically generated.

In the following C# code example, device is assumed to be the rendering Device. Developers should also check to ensure that the hardware supports the X8R8G8B8 format.

              [C#]
              
//Check cube texture requirements.
CubeTextureRequirements tr = new CubeTextureRequirements();

tr.Format = Format.A8R8G8B8;

TextureLoader.CheckCubeTextureRequirements(device, 0,
                                           Pool.Managed, out tr);
    
//Create texture.
CubeTexture cube = new CubeTexture( device, 16, 0, 0, Format.X8R8G8B8, Pool.Managed );