private void CreateCubeTexture()
{
Debug.Assert( SrcWidth > 0 && SrcHeight > 0 );
// use current back buffer format for render textures, else use the one
// defined by this texture format
D3D.Format d3dPixelFormat =
( Usage == TextureUsage.RenderTarget ) ? _bbPixelFormat : ChooseD3DFormat();
// set the appropriate usage based on the usage of this texture
D3D.Usage d3dUsage =
( Usage == TextureUsage.RenderTarget ) ? D3D.Usage.RenderTarget : 0;
// how many mips to use? make sure its at least one
int numMips = ( MipmapCount > 0 ) ? MipmapCount : 1;
if ( ( _devCaps.TextureCaps & D3D.TextureCaps.MipCubeMap ) != D3D.TextureCaps.MipCubeMap )
{
if ( this.CanAutoGenMipMaps( d3dUsage, D3D.ResourceType.CubeTexture, d3dPixelFormat ) )
{
d3dUsage |= D3D.Usage.AutoGenerateMipMap;
numMips = 0;
}
}
else
{
// no mip map support for this kind of texture
MipmapCount = 0;
numMips = 1;
}
// create the cube texture
_cubeTexture = new D3D.CubeTexture(
_device,
SrcWidth,
numMips,
d3dUsage,
d3dPixelFormat,
( Usage == TextureUsage.RenderTarget ) ? D3D.Pool.Default : D3D.Pool.Managed );
// store base reference to the texture
_texture = _cubeTexture;
// set the final texture attributes
D3D.SurfaceDescription desc = _cubeTexture.GetLevelDescription( 0 );
SetFinalAttributes( desc.Width, desc.Height, 1, D3DHelper.ConvertEnum( desc.Format ) );
// store base reference to the texture
_texture = _cubeTexture;
if ( this.MipmapsHardwareGenerated )
_texture.AutoMipGenerationFilter = GetBestFilterMethod();
}