Tutorial *22*

The Quake II engine source is out, and now Im being the first to write a tutorial for it!
For this tutorial, we are going to make Quake II load targa files instead of wal files in the case that a targa exists with the same filename as the texture thats being loaded. A short but sweet tutorial to add some true colour goodness to the engine.

Open up the ref_gl project, and look to the source file gl_model.c, and move to the function Mod_LoadTexinfo. gl_model.c controls loading models. Remember, maps - like players - are models too. Mod_LoadTexinfo is the function that reads all the textures referenced in a map.

Find the lines that read:
Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);

out->image = GL_FindImage (name, it_wall);
This is what actually loads the texture named 'name' from the .wal texture file. We want to only execute this if we havn't already loaded a replacement texture. So, we shall encapsulate them in an if statement like so:
if (!out->image) {

	Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);

	out->image = GL_FindImage (name, it_wall);

}

Now we can tell if a targa has been loaded already, and if it hasnt we load our old .wal file. Now to load the targa, we will move directly above that code and add in the following:
Com_sprintf (name, sizeof(name), "textures/%s.tga", in->texture);

out->image = GL_FindImage (name, it_wall);

Thats it! Now you can add targa textures into Quake2 for some true colour fun!


 
Sign up
Login:
Passwd:
[Remember Me]