Back to index

extremetuxracer  0.5beta
Functions | Variables
fog.cpp File Reference
#include "fog.h"
#include "gl_util.h"
#include "tcl_util.h"
#include "game_config.h"

Go to the source code of this file.

Functions

static int fog_cb (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])

Variables

FogPlane fogPlane

Function Documentation

static int fog_cb ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
) [static]

Definition at line 66 of file fog.cpp.

{
    double tmp_arr[4];
    double tmp_dbl;
    bool error = false;
    
    if (argc < 2) {
              error = true;
    }

    NEXT_ARG;

    while ( !error && argc > 0 ) {

       if ( strcmp( "-on", *argv ) == 0 ) {
           fogPlane.setEnabled();
       } else if ( strcmp( "-off", *argv ) == 0 ) {
           fogPlane.setEnabled(false);
       } else if ( strcmp( "-mode", *argv ) == 0 ) {
           NEXT_ARG;
           if ( argc == 0 ) {
                     error = true;
                     break;
           }

           if ( strcmp( "exp", *argv ) == 0 ) {
                     fogPlane.setMode(GL_EXP);
           } else if ( strcmp( "exp2", *argv ) == 0 ) {
                     fogPlane.setMode(GL_EXP2);
           } else if ( strcmp( "linear", *argv ) == 0 ) {
                     fogPlane.setMode(GL_LINEAR);
           } else {
                     print_warning( TCL_WARNING, "tux_fog: mode must be one of "
                            "`exp', `exp2', or `linear'" );
                     error = true;
           }
       } else if ( strcmp( "-density", *argv ) == 0 ) {
           NEXT_ARG;
           if ( argc == 0 ) {
                     error = true;
                     break;
           }
              if ( Tcl_GetDouble ( ip, *argv, &tmp_dbl ) == TCL_ERROR ) {
                     error = true;
                     break;
           }
           fogPlane.setDensity(tmp_dbl);
       } else if ( strcmp( "-start", *argv ) == 0 ) {
           NEXT_ARG;
           if ( argc == 0 ) {
                     error = true;
                     break;
           }
           if ( Tcl_GetDouble ( ip, *argv, &tmp_dbl ) == TCL_ERROR ) {
                     error = true;
                     break;
           }
           fogPlane.setStart(tmp_dbl);
       } else if ( strcmp( "-end", *argv ) == 0 ) {
           NEXT_ARG;
           if ( argc == 0 ) {
                     error = true;
                     break;
           }
           if ( Tcl_GetDouble ( ip, *argv, &tmp_dbl ) == TCL_ERROR ) {
                     error = true;
                     break;
           }
           fogPlane.setEnd(tmp_dbl);
       } else if ( strcmp( "-color", *argv ) == 0 ) 
       {
           NEXT_ARG;
           if ( argc == 0 ) {
                     error = true;
                     break;
           }
           if ( get_tcl_tuple ( ip, *argv, tmp_arr, 4 ) == TCL_ERROR ) {
                     error = true;
                     break;
           }
           copy_to_glfloat_array( fogPlane.getColor(), tmp_arr, 4 );
       } else {
           print_warning( TCL_WARNING, "tux_fog: unrecognized "
                        "parameter `%s'", *argv );
       }

       NEXT_ARG;
    }

    if ( error ) {
       print_warning( TCL_WARNING, "error in call to tux_fog" );
       Tcl_AppendResult(
           ip, 
           "\nUsage: tux_fog [-on|-off] "
           "[-mode [exp|exp2|linear]] "
           "[-density <value>] "
           "[-start <value>] "
           "[-end <value>] "
           "[-color { r g b a }] ",
           (char *) 0 );
       return TCL_ERROR;
    }
    
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 29 of file fog.cpp.