Wireframe Mode

 

Copyright info

All code in this tutorial is protected by the [GPL License].
All text in this tutorial is protected by the [FDL License].

 

Tutorial by: S.E.B.

Mailto: seb@vjc-quake.be.tf

Ok , this one is easy, I’ve found it although I’ve got only a couple months experience with C and OpenGL. (I’m programming for a couple of years but in Delphi)

Ok , here we go:

Step 1 : open the ref_gl.dll source. Go to gl_rmain.c find the place where all the cvar’s are declared and add.

 
 
cvar_t *gl_wire; //SEB
 
     

Step 2: find the function R_Register still in gl_rmain.c and add somewhere in there

 
 
gl_wire = ri.Cvar_Get ("gl_wire", "0", 0); //SEB
 
     

Step 3 : find the function R_Renderview and seek for the lines

 
 
R_MarkLeaves (); // done here so we know if we're in water
 
R_DrawWorld ();
 
R_DrawEntitiesOnList ();
 
     

Replace them with

 
 
R_MarkLeaves (); // done here so we know if we're in water
 
if (gl_wire->value) qglPolygonMode (GL_FRONT_AND_BACK, GL_LINE); //SEB
 
R_DrawWorld ();
 
if (gl_wire->value) qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); //SEB
 
R_DrawEntitiesOnList ();
 
     

or if you want to display models wired to :

 
 
R_MarkLeaves (); // done here so we know if we're in water
 
if (gl_wire->value) qglPolygonMode (GL_FRONT_AND_BACK, GL_LINE); //SEB
 
R_DrawWorld ();
 
R_DrawEntitiesOnList ();
 
if (gl_wire->value) qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); //SEB
 
     

Step 4: If you try to run quake with your dll now it will look very weird if you turn on the wireframe mode. This is because the screen isn’t cleared , so to do this , add the next function above R_RenderFrame

 
 
void Draw_BlackScreen (void)//SEB
{
GLSTATE_DISABLE_ALPHATEST
GLSTATE_ENABLE_BLEND
qglDisable (GL_TEXTURE_2D);
qglColor4f (0, 0, 0, 1); // here you can set the color 0,0,0 is just black , white looks nice too.
 
VA_SetElem2(vert_array[0],0,0);
VA_SetElem2(vert_array[1],vid.width, 0);
VA_SetElem2(vert_array[2],vid.width, vid.height);
VA_SetElem2(vert_array[3],0, vid.height);
qglDrawArrays (GL_QUADS, 0, 4);
 
qglColor4f (1,1,1,1);
qglEnable (GL_TEXTURE_2D);
GLSTATE_DISABLE_BLEND
GLSTATE_ENABLE_ALPHATEST
}
 
     

Step 5 : look at the function R_RenderFrame and replace :

 
 
R_RenderView( fd );
R_SetLightLevel ();
R_SetGL2D ();
 
     

With

 
 
if (gl_wire->value) Draw_BlackScreen ();//SEB
R_RenderView( fd );
R_SetLightLevel ();
R_SetGL2D ();
 
     

Well this should be it , in your console type gl_wire 1 to turn on the wired mode.You could add some fancy stuff like a cvar for turning the model to wireframe without the world , or the world alone , or to set the background color. It shouldn’t be too difficult. I use it to test my own level , too see exactly which polygons are drawn and which aren’t. It’s also a good wallhack but I didn’t made this to spoil multiplayer games, so don’t use it if you go play on-line.

 

 

Tutorial Originally found at: