Introduction to Programming
MAK Library Reference
Initialization
The makInit() function initializes the library. You should call it from main once you are done
setting up the starting value of your global variables. Note that this function will
not return to main until the user closes the window, effectively
ending your program. So you should only call makInit at the end
of main.
makInit() takes 3 arguments. The first two are the width and height of the window you want
to use. I like to use 640 by 480, since that will fit on just about any monitor. The final argument
is a pointer to a function that you create.
makInit(width, height, &callback)
Callback Function
This will be the function where you put all your drawing, and where you update your global values.
It gets called once every frame -- that is, your function will run once every time the screen is drawn.
If your computer is fast enough, and your drawing function simple enough, this function can get
called up to 100 times per second.
You can name your function whatever you want, but it must take exactly one argument. This argument
must be an "int", but you can name the argument whatever you want. Each time your function gets
called, this integer will have the frame number in it. In other words, the first time your function
gets called, the argument will be 0. The second time, it will be 1, the third time it will be 2, etc.
void callback(int frameNumber)
{
}
Drawing Functions
Call these functions within your callback function to put something on the screen.
makDrawSphere(x, y, z, radius);
makDrawCube(x, y, z, xSize, ySize, zSize);
makDrawTexCubeParts(textureNumber, x, y, z, xSize, ySize, zSize, mask);
makDrawSquare(x, y, z, xSize, ySize);
makDrawTexSquare(textureNumber, x, y, z, xSize, ySize);
makDrawString(x, y, z, string);
Changing the Look
Call these functions to change the way the above objects look on the screen.
makSetCamera(x, y, z, targetX, targetY, targetZ);
makSetColor(red, green, blue);
makSetLight(lightNumber, red, green, blue, x, y, z);
makLightOut(lightNumber);
makSetTexture(textureNumber, tgaFileName);
Input
Call this function to find out if the given key is pressed. Note that characters have to have single
quotes around it! (So say 'A' instead of just A). This library requires that you use uppercase letters
even when you want to find out if they pressed the lowercase version. (So say 'A' instead of 'a').
makGetKey('KEY');
Done?
If at any point you want your program to end (say, if the user presses a particular key), simply call the makQuit() function.
makQuit();
Stay Tuned!
Soon I will put up an explanation of what each of the above functions does, and how to use them.
In the mean time, feel free to experiment with them, and see if you
can figure out what they do!