Back to index

extremetuxracer  0.5beta
Defines | Functions
lights.h File Reference
#include "pp_types.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define NUM_COURSE_LIGHTS   8

Functions

light_tget_course_lights ()
void reset_lights ()
void setup_course_lighting ()
void register_course_light_callbacks (Tcl_Interp *ip)

Define Documentation

#define NUM_COURSE_LIGHTS   8

Definition at line 27 of file lights.h.


Function Documentation

Definition at line 28 of file lights.cpp.

                             { 
    return course_lights; 
}
void register_course_light_callbacks ( Tcl_Interp *  ip)

Definition at line 265 of file lights.cpp.

{
    Tcl_CreateCommand (ip, "tux_course_light", course_light_cb, 0,0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void reset_lights ( )

Definition at line 33 of file lights.cpp.

{
    int i;
    GLfloat black[] = { 0., 0., 0., 1. };
    for (i=0; i<NUM_COURSE_LIGHTS; i++) {
       /* Note: we initialize the lights to default OpenGL values
           EXCEPT that light 0 isn't treated differently than the
           others */
       course_lights[i].is_on = false;
       init_glfloat_array( 4, course_lights[i].ambient, 0., 0., 0., 1. );
       init_glfloat_array( 4, course_lights[i].diffuse, 0., 0., 0., 1. );
       init_glfloat_array( 4, course_lights[i].specular, 0., 0., 0., 1. );
       init_glfloat_array( 4, course_lights[i].position, 0., 0., 1., 0. );
       init_glfloat_array( 3, course_lights[i].spot_direction, 0., 0., -1. );
       course_lights[i].spot_exponent = 0.0;
       course_lights[i].spot_cutoff = 180.0;
       course_lights[i].constant_attenuation = 1.0;
       course_lights[i].linear_attenuation = 0.0;
       course_lights[i].quadratic_attenuation = 0.0;
    }

    /* Turn off global ambient light */
    glLightModelfv( GL_LIGHT_MODEL_AMBIENT, black );
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 58 of file lights.cpp.

{
    int i;
    light_t *course_lights;

    course_lights = get_course_lights();

    for (i=0; i<NUM_COURSE_LIGHTS; i++) {
       if ( ! course_lights[i].is_on ) {
           glDisable( GL_LIGHT0 + i );
           continue;
       }
       glEnable( GL_LIGHT0 + i );

       glLightfv( GL_LIGHT0 + i, GL_AMBIENT, course_lights[i].ambient );
       glLightfv( GL_LIGHT0 + i, GL_DIFFUSE, course_lights[i].diffuse );
       glLightfv( GL_LIGHT0 + i, GL_SPECULAR, course_lights[i].specular );
       glLightfv( GL_LIGHT0 + i, GL_POSITION, course_lights[i].position );
       glLightfv( GL_LIGHT0 + i, GL_SPOT_DIRECTION, 
                 course_lights[i].spot_direction );
       glLightf( GL_LIGHT0 + i, GL_SPOT_EXPONENT, 
                course_lights[i].spot_exponent );
       glLightf( GL_LIGHT0 + i, GL_SPOT_CUTOFF, 
                course_lights[i].spot_cutoff );
       glLightf( GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, 
                course_lights[i].constant_attenuation );
       glLightf( GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, 
                course_lights[i].linear_attenuation );
       glLightf( GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, 
                course_lights[i].quadratic_attenuation );
    }
}

Here is the call graph for this function: