Axiom.RenderSystems.OpenGL.GLTexture.load C# (CSharp) Метод

load() защищенный Метод

protected load ( ) : void
Результат void
		protected override void load()
		{
			if ( IsLoaded )
				return;

			if ( Usage == TextureUsage.RenderTarget )
			{
				CreateRenderTexture();
				return;
			}

			if ( Name.IndexOf( '.' ) == -1 )
				throw new Exception( "Unable to load image file '" + Name + "' - invalid extension." );

			string baseName = Name.Substring( 0, Name.LastIndexOf( '.' ) );
			string ext = Name.Substring( Name.LastIndexOf( '.' ) + 1 );

			Image image;
			Stream stream = null;

			if ( TextureType == TextureType.TwoD
				|| TextureType == TextureType.OneD
				|| TextureType == TextureType.ThreeD )
			{
				// find & load resource data into stream to allow resource
				// group changes if required
				stream = ResourceGroupManager.Instance.OpenResource( Name, Group, true, this );
				image = Image.FromStream( stream, ext );

				// If this is a cube map, set the texture type flag accordingly.
				if ( image.HasFlag( ImageFlags.CubeMap ) )
					TextureType = TextureType.CubeMap;

				// If this is a volumetric texture set the texture type flag accordingly.
				if ( image.Depth > 1 )
					TextureType = TextureType.ThreeD;

				// Call internal _loadImages, not loadImage since that's external and
				// will determine load status etc again
				LoadImages( new Image[] { image } );
			}
			else if ( TextureType == TextureType.CubeMap )
			{
				if ( Name.EndsWith( ".dds" ) )
				{
					// find & load resource data intro stream to allow resource
					// group changes if required
					stream = ResourceGroupManager.Instance.OpenResource( Name, Group, true, this );
					image = Image.FromStream( stream, ext );

					// Call internal _loadImages, not loadImage since that's external and
					// will determine load status etc again
					LoadImages( new Image[] { image } );
				}
				else
				{
					string[] postfixes = { "_rt", "_lf", "_up", "_dn", "_fr", "_bk" };
					List<Image> images = new List<Image>();

					for ( int i = 0; i < 6; i++ )
					{
						string fullName = baseName + postfixes[ i ] + "." + ext;

						// load the image
						stream = ResourceGroupManager.Instance.OpenResource( fullName, Group, true, this );
						image = Image.FromStream( stream, ext );

						images.Add( image );
					} // for

					// load all 6 images
					LoadImages( images.ToArray() );
				}
			}
			else
			{
				throw new NotImplementedException( "Unknown texture type." );
			}

			if ( stream != null )
				stream.Close();
		}