Created By: legion
eMail: legion@sincero.com
Difficulty Scale: Easy


One of the things that makes "DLL programming" such an improvement over QuakeC (and other limited scripted language) is that the programmer can introduce new graphical features into the game such as fog. This addition, however, is nowhere near as flexible nor as "powerful" as having access to the actual graphical 3D engine but one can add fog in a limited fashion to their mods. The fog tutorial is exceptionally easy. With a few steps, you can add fog similar to the following:

       

The first time I have seen fog in Quake II were the screenshots shown by Rohan of the Navy Seal II TC. Chemical Existance also planned to feature fog in their TC before switching to Half-life. I, myself, did not have the opportunity to see how theirs look liked. These two TCs are the only two TCs that I am aware of that planned to include fog.

This tutorial is a remake of Rohan's original fog tutorial. It is hoped that this tutorial is easier to understand than Rohan's original.

The first thing you need to know is that you need to have an OpenGL v1.1 compliant video card. The nVidia Riva TNT is an example of a compliant card. If you do not have a compliant card, you won't see any changes to the game. That is, you won't see any fog. For "pseudo-compliant" cards such as the 3dfx cards (eg. Voodoo II), you will need the mesa drivers. Download these mesa drivers and follow the instructions contained within on how to install them. I do not use these drivers since I do not need a "pseudo-opengl" card to try out fog. Contact the authors of those drivers for further instructions.

Ryche also remade Rohan's tutorial to provide instructions to compile the code using LCC. He also provided the download link for the mesa drivers, too. I use Visual C++ v6.0 so this tutorial is based on VC v6.0. I am not familiar with LCC. If you want to use this tutorial with LCC, you are better off following Ryche's tutorial.

Part 1: Adding OpenGL support
The first thing you need to do is to make sure that your compiler knows that you want the OpenGL library to be part of your project. The library (like any libraries) contains compiled code that you can use within your program. This OpenGL library is simply a collection of code you can use. So when VC compiles and then links, it would know to include code from the OpenGL library.

You have completed adding OpenGL support to your Visual C++ workspace.

Part 2: Adding OpenGL Fog
After adding OpenGL support to your workspace, you are now ready to use them in your code.

Fog is a graphical feature. This means that fog needs to be "drawn" on the screen. All the "drawing" is performed by Quake2.exe. Since you are adding fog to the game code and not to the quake2.exe itself, you need to make sure that the fog code is executed every frame. Otherwise, when quake2.exe "draws" another frame it will "overwrite" any fog in the previous frame and "erase" it. You can add the fog code snippet anywhere in your mod as long as it is called every frame.