Axiom.RenderSystems.DirectX9.D3DTexture.CreateSurfaceList C# (CSharp) Метод

CreateSurfaceList() приватный метод

private CreateSurfaceList ( ) : void
Результат void
		private void CreateSurfaceList()
		{
			Debug.Assert( this._texture != null, "texture must be intialized." );
			D3D.Surface surface;

			// Make sure number of mips is right
			_mipmapCount = this._texture.LevelCount - 1;

			// Need to know static / dynamic
			BufferUsage bufusage;
			if ( ( ( Usage & TextureUsage.Dynamic ) != 0 ) && this._dynamicTextures )
			{
				bufusage = BufferUsage.Dynamic;
			}
			else
			{
				bufusage = BufferUsage.Static;
			}

			if ( ( Usage & TextureUsage.RenderTarget ) != 0 )
			{
				bufusage = (BufferUsage)( (int)bufusage | (int)TextureUsage.RenderTarget );
			}

			// If we already have the right number of surfaces, just update the old list
			bool updateOldList = ( this._surfaceList.Count == ( faceCount * ( MipmapCount + 1 ) ) );
			if ( !updateOldList )
			{
				// Create new list of surfaces
				this.ClearSurfaceList();
				for ( int face = 0; face < faceCount; ++face )
				{
					for ( int mip = 0; mip <= MipmapCount; ++mip )
					{
						D3DHardwarePixelBuffer buffer = new D3DHardwarePixelBuffer( bufusage );
						this._surfaceList.Add( buffer );
					}
				}
			}

			switch ( TextureType )
			{
				case TextureType.OneD:
				case TextureType.TwoD:
					Debug.Assert( this._normTexture != null, "texture must be intialized." );

					// For all mipmaps, store surfaces as HardwarePixelBuffer
					for ( int mip = 0; mip <= MipmapCount; ++mip )
					{
						surface = this._normTexture.GetSurfaceLevel( mip );
						this.GetSurfaceAtLevel( 0, mip ).Bind( this._device, surface, updateOldList );
						this._managedObjects.Add( surface );
					}

					break;

				case TextureType.CubeMap:
					Debug.Assert( _cubeTexture != null, "texture must be initialized." );

					// For all faces and mipmaps, store surfaces as HardwarePixelBuffer
					for ( int face = 0; face < 6; ++face )
					{
						for ( int mip = 0; mip <= MipmapCount; ++mip )
						{
							surface = this._cubeTexture.GetCubeMapSurface( (D3D.CubeMapFace)face, mip );
							this.GetSurfaceAtLevel( face, mip ).Bind( this._device, surface, updateOldList );
							this._managedObjects.Add( surface );
						}
					}

					break;

				case TextureType.ThreeD:
					Debug.Assert( _volumeTexture != null, "texture must be intialized." );

					// For all mipmaps, store surfaces as HardwarePixelBuffer
					for ( int mip = 0; mip <= MipmapCount; ++mip )
					{
						D3D.Volume volume = this._volumeTexture.GetVolumeLevel( mip );
						this.GetSurfaceAtLevel( 0, mip ).Bind( this._device, volume, updateOldList );
						this._managedObjects.Add( volume );
					}

					break;
			}

			// Set autogeneration of mipmaps for each face of the texture, if it is enabled
			if ( ( RequestedMipmapCount != 0 ) && ( ( Usage & TextureUsage.AutoMipMap ) != 0 ) )
			{
				for ( int face = 0; face < faceCount; ++face )
				{
					this.GetSurfaceAtLevel( face, 0 ).SetMipmapping( true, MipmapsHardwareGenerated, this._texture );
				}
			}
		}