Game Development Reference
In-Depth Information
Next, the TextureManager loads the texture data from the disk and associates
it with an id provided by OpenGL. The texture is also associated with a human
readable name so that it's easy to work with. The code to load the texture re-
quires an additional reference, Tao.DevIl , to be added to the project. Add it
the same way you added Tao.OpenGL . DevIl is short for Developer's Image
Library. It can load most image formats so that OpenGL can use them.
The DevIL library also requires a number of DLL files to run; these must be in the
same directory as your binary file. This directory will probably be bin\debug .
Find the Tao Framework directory; it will most likely be in your C:\Program
File (x86) (or the C:\Program Files directory on Windows XP). Navigate to
\TaoFramework\lib and copy DevIl.dll, ILU.dll, and ILUT.dll into your bin
\debug directory. When you do a release build, you will need to copy all re-
levant dlls to bin\release, too. Once this is done you can start using DevIl.
The DevIl library has to be initialized and told to work with OpenGL. Form.cs is
a good place to initialize DevIl. Make sure you add the using statement, as
shown below, to the top of the Form.cs file.
using Tao.DevIl;
Then in the form's constructor, add the following code.
// Init DevIl
Il.ilInit();
Ilu.iluInit();
Ilut.ilutInit();
Ilut.ilutRenderer(Ilut.ILUT_OPENGL);
Create a new class called TextureManger . At the top, add the using state-
ments for DevIl and OpenGL.
Here's the basic TextureManager code
class TextureManager : IDisposable
{
Dictionary<string, Texture> _textureDatabase = new Dictionary<string,
Texture>();
public Texture Get(string textureId)
{
return _textureDatabase[textureId];
}
 
Search WWH ::




Custom Search