Game Development Reference
In-Depth Information
You will need to reference System.IO for the MemoryStream object, as well as System.Drawing
for the Bitmap object. Additionally, you will need to reference both Microsoft.DirectX and
Microsoft.DirectX.Direct3D for the Managed Direct3D support.
Storing Texture Information
The texture browser will support three ways of loading an image as a texture: from
an image file stored on the local hard drive, from raw binary data in memory, and
from a preloaded bitmap. In order to provide a unified and straightforward way of
accessing textures that are loaded in the browser, we need to create a container
class that wraps the three load methods into a common interface. This interface
will be known as a texture handle ; it will store the appropriate data depending on
the source of the image, and it will keep track of simple state information to sup-
port caching.
Texture handles will need to keep track of the image data and where the data orig-
inated from, so the enum defined below will be used to accomplish this.
public enum TextureHandleType
The texture handle class has several different constructors, each with a different
signature and parameter list. The texture handle type is set when one of the con-
structors is fired, and depending on the constructor, the appropriate type value is
If one of the constructors accepting a FileInfo object is used, then it is assumed
that the image is being loaded from the hard drive, so the handle type will be set
to TextureHandleType.FileSystem .
If a constructor is used that accepts a Bitmap object, it is assumed that the object
contains the image data, and the handle type should be set to TextureHandleType.Bitmap .
Lastly, if a constructor is used that accepts a MemoryStream object, it is assumed that
the memory stream contains the raw binary data of the image, and that the han-
dle type should be set to TextureHandleType.MemoryStream .
Search Nedrilad ::

Custom Search