http://nehe.gamedev.net (though, since you are reading this tutorial now, you are already there). :)
Now, lets start at the top of the shining3d.h header file. It starts by including some necessary files that we will need
at one time or another, and then it include the DirectInput8 header file, as well as some OpenGL headers. And in
case, you aren't familiar with the following code, I will explain it briefly:
#pragma comment(lib, "Dxguid.lib") // Search For the DXguid Library At
Compile Time
#pragma comment(lib, "Dinput8.lib") // Search For the DirectInput8
Library At Compile Time
#pragma comment(lib, "OpenGL32.lib") // Search For The OpenGL32 Library At
Compile Time
#pragma comment(lib, "Glu32.lib") // Search For The Glu32 Library At
Compile Time
Those lines search for the correct library (provided in the quotation marks) at compile time, that way, you don't
have to include those libraries every time you want to compile the program. Sorta helpful. ;)
Next, let's jump to the classes! The first class is the main class that you will always need in your programs.
class SHINING3D
{
Now, lets start by going through the private variables of the class. And just for a little refresher, the private parts of
a class can only be accessed by information IN that class. For example, say you wanted to access a private int
"bob." You could access "bob" in absolutely any function within that class, but if the user wanted to access "bob"
from within their program, it would not be possible. Get it? Hopefully, because I just drank the last Mountain Dew in
my house. Anyway, here are the private variables:
GLuint base;
S3DTGA font_texture;
These are both used for the font functions that we have. Now here are the font functions (you'll notice that I am
jumping around the class a little, so bare with me :) ):
GLvoid glPrint(GLint x, GLint y, const char *string, ...);
GLvoid Font_Init(GLvoid);
GLvoid Font_Shutdown(GLvoid);
You will need to put Font_Init() in the initiation part of the console if you want to use the font printing function.
Similarly, you will need to put Font_Shutdown() in the shutdown part of the console. glPrint(GLint x, GLint y, const
char *string, ...) will print text that you provide for the third argument, at the location you provide for the first two
arguments. You can go to the main console (main.cpp) to see an example of using the function right now. I will fully
explain the main console (I call it a console, you can call it "the main file," "the main template," "the main
framework," or whatever floats your pickle... Or is that "tickles your boat?" I always seem to forget...) later on in the
tutorial. Anyway, now you understand what each font function does, if you want further information on fonts, you
can check out the functions' definition in shining3d.cpp or go to NeHe's tutorials on fonts, which are Tutorials 13-15.
Next on the list, (back to the private functions) is the cosine and sine initiation function. Here is the declaration:
GLvoid SIN_COS_Init(GLvoid);
And, even though the function is already called when the program starts (this is accomplished by using the class's
constructor. A quick explanation of this is that anything in the constructor is done when the program starts), I will be
going through the function definition anyway. The definition is in math.cpp. And here it is:
GLvoid SHINING3D::SIN_COS_Init(GLvoid)
{
GLuint loop; // Looping Index, For The
http://nehe.gamedev.net/gametutorials/lesson01.asp (2 of 11) [20/08/2001 22:34:03]