mario::konrad
programming / C++ / sailing / nerd stuff
C++ Graphics Utils
© 2005 / Mario Konrad

camera

This class is intended to have a camera that supports all degrees of freedom you could ever want (6 degrees of freedom). It takes advantage of the two earlier introduced classes vector3 and quaternion. This class is dependent on the GLU (OpenGL) library (functions gluPerspective and gluLookAt).

There is no example for this class, just look at the comments and the class declaration (header file).

fpscounter

This class help to determine the amount of frames that are drawn per second (FPS = frames per second). I usually use them in my OpenGL programs.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cg::fpscounter fps;

void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    ...
    ...
    ftp.tick();
    glFlush();
    glutSwapBuffers();
}

...
cout << fps.get_fps() << endl;

This FPS counter is for Unix environments (Linux, Cygwin, etc.) only.

isqrt

This function calculates the integer square root of a given number.

1
2
3
4
5
6
7
unsigned int isqrt(unsigned int val)
{
    unsigned int c = 1;
    unsigned int r = 0;
    for (unsigned sum = 0; sum < val; ++r, c += 2) sum += c;
    return r;
}