Axiom.RenderSystems.DirectX9.D3DTexture.LoadVolumeTexture C# (CSharp) Method

LoadVolumeTexture() private method

private LoadVolumeTexture ( ) : void
return void
		private void LoadVolumeTexture()
		{
			Debug.Assert( this.TextureType == TextureType.ThreeD );

			if ( Name.EndsWith( ".dds" ) )
			{

				Stream stream = ResourceGroupManager.Instance.OpenResource( Name, Group, true, this );

				int numMips = this.RequestedMipmapCount + 1;
				// check if mip map volume textures are supported
				if ( ( _devCaps.TextureCaps & D3D.TextureCaps.MipVolumeMap ) != D3D.TextureCaps.MipVolumeMap )
				{
					// no mip map support for this kind of textures :(
					this.MipmapCount = 0;
					numMips = 1;
				}

				_d3dPool = ( Usage & TextureUsage.Dynamic ) != 0 ? D3D.Pool.Default : D3D.Pool.Managed;

				try
				{
					// load the cube texture from the image data stream directly
					_volumeTexture = D3D.VolumeTexture.FromStream( _device, stream, (int)stream.Length, -1, -1, -1, numMips, D3D.Usage.None, D3D.Format.Unknown, _d3dPool, D3D.Filter.None, D3D.Filter.None, 0 );
				}
				catch ( Exception ex )
				{
					FreeInternalResources();
					throw new Exception( "Can't create volume texture.", ex );
				}

				// store off a base reference
				_texture = _volumeTexture;

				// set src and dest attributes to the same, we can't know
				D3D.VolumeDescription desc = _volumeTexture.GetLevelDescription( 0 );
				_d3dPool = desc.Pool;

				SetSrcAttributes( desc.Width, desc.Height, desc.Depth, D3DHelper.ConvertEnum( desc.Format ) );
				SetFinalAttributes( desc.Width, desc.Height, desc.Depth, D3DHelper.ConvertEnum( desc.Format ) );

				internalResourcesCreated = true;

				stream.Close();
			}
			else
			{

				// find & load resource data intro stream to allow resource group changes if required
				Stream strm = ResourceGroupManager.Instance.OpenResource( Name, Group, true, this );
				int pos = Name.LastIndexOf( "." );
				String ext = Name.Substring( pos + 1 );

				// Call internal LoadImages, not LoadImage since that's external and
				// will determine load status etc again
				var image = Image.FromStream( strm, ext );
				LoadImages( new Image[] { image } );
				image.Dispose();

				strm.Close();
			}
		}