INTRODUCTION TO SPACE RACER FOR NEWBEES
=======================================

v0.1.1 19991014 Thomas Lund (tld@carlbro.dk)

Requirements: basic C/C++ and 3D thinking

OPENGL
------

_not done_

First hurdle: opengl

3 parts: gl, glu and glut

GL basic lowlevel interface
GLU more shapes and such
GLUT higher level interface to some of GL functions. Also very basic menu, handles keyboard, mouse and other input (not joystick) devices. Qutite simple and easy.

To learn it, read first

http://www.eecs.tulane.edu/www/Terry/OpenGL/Introduction.html

which is an excellent basic tutorial, that takes you through most of the GL stuff around. It is a bit outdated, since it uses the tk lib, that is the predecessor of GLUT. But the interface is very identical, and the examples are good.

After that look at GLUT.

The GLUT API is described in both HTML and PostScript here:
http://reality.sgi.com/opengl/glut3/#7

Print it and you have a handy reference book for GLUT. You can skim it, but it's better as a reference.

Looking at examples at the same time as you have the documentation handy is good. Whats missing is som GL documentation besiden the tutorial above. 

DEC has made man pages for all GL and GLU commands.

http://www.eecs.tulane.edu:80/www/graphics/doc/OpenGL-Man-Pages/index.html

Very nice.

If you are on Linux and do not own the OpenGL libs, then you need Mesa to compile the programs. Go to www.mesa3d.org and DL the source. Install and youre set. Be sure to compile the demos. In the util dir there is a good skeleton for your first GLUT program. It's called glutskel.c. You more or less only have to draw some objects using GL.

Where it says 
/* draw stuff here */
try putting

glBegin(GL_QUADS);
glVertex3i(0,1,2);
glVertex3i(0,3,2);
glVertex3i(12,3,2);
glVertex3i(12,1,2);
glEnd();


try to compile it with something like

gcc glutskel.c -o glutskel -L/usr/X11R6/lib -lX11 -lglut -lMesaGLU -lMesaGL -lXmu -lXext -lXt -lXi

and run.

For some great tutorial programs look here:

http://www.xmission.com/~nate/tutors.html

They are interactive demos of some of the features in OpenGL. Just point your mouse at the variables, and you can change them by dragging. The code you see can more or less be implemented in the display function in your own program.

Download the sources and data files.

There is no Makefile for Linux, but you can compile the programs with:
gcc -c sgi.c 
gcc -c glm.c 

and then for each of the programs (substitute texture with one of the programs)

gcc texture.c -o texture -L/usr/X11R6/lib -lX11 -lglut -lMesaGLU -lMesaGL -lXmu -lXext -lXt -lXi sgi.o glm.o

Run and learn! It's as easy as that.

From here on you are on your own with GL. Try drawing some simple objects on paper that has a grid. Try drawing your object in GL as QUADS and TRIANGLES. It's quite easy.

The not so easy part is setting up lighting, colors and materials. It takes some practice before you're good at it.

All examples I've seen are build on basicly the same skeleton. Look in the main() function to see what function is the display and which is the idle. The take a look at those, and what the program does. After 3-4 programs you get the hang of it.

Tips:
Try using TRIANGLES as much as possible. Most graphic cards have hardware support of them, but not other shapes. A game like Quake only uses TRIANGLES to get the fastest speed.

There are 2 types of scenes in OpenGL: FRUSTRUM and ORTHO. The difference is that in FRUSTRUM objects that are further into the scene are rendered smaller than object near the camera. In ORTHO all objects have the same size no matter where they are in the box. That one took me a while to understand.

After rotating and translating around in the scene, use glLoadIdentity(); to reset yourself to the 0,0,0 spot. 

If you draw a 3D object all lines that are behind other lines will shine through. To disable this behaviour you have to glEnable(GL_DEPTH_TEST); and cleat the GL_DEPTH_BUFFER_BIT with glClear(GL_DEPTH_BUFFER_BIT);. Also have glutInitDisplayMode( *other modes* | GLUT_DEPTH);. Thats it!


SPACE RACER
-----------

_soon_


DISCLAIMER
----------

I am not liable for any damage that might occur running these programs. Use at you own risk.

If I have made errors, please contact me to fix them.
