Game Development Reference
In-Depth Information
Texture handles need a humanly readable way to distinguish themselves from one
another. Since the image data does not have to come from the file system and can
come directly from raw memory, the filename cannot be used as an identifier. It is
for this reason that the Name property was introduced into the texture handle class.
The two boolean properties Generate and Loaded will be covered later in this chap-
ter. They are flags describing whether or not the textures need to be regenerated,
and whether or not the image itself was able to be loaded.
You should also notice that the TextureHandle class implements the IDisposable
interface. This is because of the MemoryStream object, which the Dispose method will
close if required.
The following code implements the texture handle class in its entirety.
public class TextureHandle : IDisposable
{
private string _name;
private FileInfo _file;
private Bitmap _image;
private MemoryStream _data;
private bool _generate = true;
private TextureHandleType _type;
private bool _loaded;
public string Name
{
get { return _name; }
set { _name = value; }
}
public FileInfo File
{
get { return _file; }
set { _file = value; }
}
public Bitmap Image
{
get { return _image; }
set { _image = value; }
}
Search Nedrilad ::




Custom Search