Back to index

extremetuxracer  0.5beta
Enumerations | Functions | Variables
gl_util.h File Reference
#include "etracer.h"
#include <GL/glext.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  RenderMode {
  GUI, GAUGE_BARS, TEXFONT, TEXT,
  COURSE, TREES, PARTICLES, PARTICLE_SHADOWS,
  BACKGROUND, TUX, TUX_SHADOW, SKY,
  FOG_PLANE, TRACK_MARKS, OVERLAYS, SPLASH_SCREEN
}

Functions

void set_gl_options (const RenderMode mode)
void copy_to_glfloat_array (GLfloat dest[], double src[], int n)
void init_glfloat_array (int num, GLfloat arr[],...)
void init_opengl_extensions ()
void print_gl_info ()

Variables

PFNGLLOCKARRAYSEXTPROC glLockArraysEXT_p
PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT_p

Enumeration Type Documentation

enum RenderMode
Enumerator:
GUI 
GAUGE_BARS 
TEXFONT 
TEXT 
COURSE 
TREES 
PARTICLES 
PARTICLE_SHADOWS 
BACKGROUND 
TUX 
TUX_SHADOW 
SKY 
FOG_PLANE 
TRACK_MARKS 
OVERLAYS 
SPLASH_SCREEN 

Definition at line 68 of file gl_util.h.


Function Documentation

void copy_to_glfloat_array ( GLfloat  dest[],
double  src[],
int  n 
)

Definition at line 370 of file gl_util.cpp.

{
    int i;
    for (i=0; i<n; i++) {
       dest[i] = src[i];
    }
}

Here is the caller graph for this function:

void init_glfloat_array ( int  num,
GLfloat  arr[],
  ... 
)

Definition at line 378 of file gl_util.cpp.

{
    int i;
    va_list args;

    va_start( args, arr );

    for (i=0; i<num; i++) {
       arr[i] = va_arg(args, double);
    }

    va_end( args );
}

Here is the caller graph for this function:

Definition at line 400 of file gl_util.cpp.

{
    get_gl_proc_fptr_t get_gl_proc;

    get_gl_proc = (get_gl_proc_fptr_t) SDL_GL_GetProcAddress;

    #ifndef NO_FUNCTION_POINTERS
    if ( get_gl_proc ) {
       glLockArraysEXT_p = (PFNGLLOCKARRAYSEXTPROC) 
           (*get_gl_proc)( (GLubyte*) "glLockArraysEXT" );
       glUnlockArraysEXT_p = (PFNGLUNLOCKARRAYSEXTPROC) 
           (*get_gl_proc)( (GLubyte*) "glUnlockArraysEXT" );
       
       if ( glLockArraysEXT_p != NULL && glUnlockArraysEXT_p != NULL ) {
           print_debug( DEBUG_GL_EXT, 
                      "GL_EXT_compiled_vertex_array extension "
                      "supported" );
       } else {
           print_debug( DEBUG_GL_EXT, 
                      "GL_EXT_compiled_vertex_array extension "
                      "NOT supported" );
           glLockArraysEXT_p = NULL;
           glUnlockArraysEXT_p = NULL;
       }
    } else {
       print_debug( DEBUG_GL_EXT, 
                   "No function available for obtaining GL proc addresses" );
    }
    #endif 
}

Here is the call graph for this function:

Here is the caller graph for this function:

void print_gl_info ( )

Definition at line 460 of file gl_util.cpp.

{
    char *extensions;
    char *p, *oldp;
    unsigned int i;
    GLint int_val;
    GLfloat float_val;
    GLboolean boolean_val;

    fprintf( stderr,
            "  vendor: %s\n", 
            glGetString( GL_VENDOR ) );

    fprintf( stderr,
            "  renderer: %s\n", 
            glGetString( GL_RENDERER ) );

    fprintf( stderr,
            "  version: %s\n", 
            glGetString( GL_VERSION ) );

       //extensions = string_copy( (char*) glGetString( GL_EXTENSIONS ) );
       //oldp = extensions;
       
       extensions = (char*) glGetString( GL_EXTENSIONS );

       oldp = new char[strlen(extensions)+1];
       extensions = oldp;
       strcpy(oldp, extensions);

    fprintf( stderr, "  extensions:\n" );
       
    while ( (p=strchr(oldp,' ')) ) {
              *p='\0';
              fprintf( stderr, "    %s\n", oldp );
              oldp = p+1;
    }
       
       if ( *oldp ) {
              fprintf( stderr, "    %s\n", oldp );
    }
       
       delete extensions;
       
    for ( i=0; i<sizeof(gl_values)/sizeof(gl_values[0]); i++) {
       fprintf( stderr, "  %s: ", gl_values[i].name );

       switch( gl_values[i].type ) {
       case GL_INT:
           glGetIntegerv( gl_values[i].value, &int_val );
           fprintf( stderr, "%d", int_val );
           break;

       case GL_FLOAT:
           glGetFloatv( gl_values[i].value, &float_val );
           fprintf( stderr, "%f", float_val );
           break;

       case GL_UNSIGNED_BYTE:
           glGetBooleanv( gl_values[i].value, &boolean_val );
           fprintf( stderr, "%d", boolean_val );
           break;

       default:
           code_not_reached();
       }

       fprintf( stderr, "\n" );
    }


    fprintf( stderr, "\n" );
}

Here is the caller graph for this function:

void set_gl_options ( const RenderMode  mode)

Definition at line 33 of file gl_util.cpp.

{
    /* Must set the following options:
         Enable/Disable:
          GL_TEXTURE_2D
          GL_DEPTH_TEST
          GL_CULL_FACE
          GL_LIGHTING
          GL_NORMALIZE
          GL_ALPHA_TEST
          GL_BLEND
          GL_STENCIL_TEST
          GL_TEXTURE_GEN_S
          GL_TEXTURE_GEN_T
          GL_COLOR_MATERIAL
           
        Other Functions:
          glDepthMask
          glShadeModel
          glDepthFunc
    */

    /*
     * Modify defaults based on rendering mode
     * 
     * This could could be improved if it stored state and avoided
     * redundant state changes, which are costly (or so I've heard)...  
     */
    switch( mode ) {
    case GUI:
        glEnable( GL_TEXTURE_2D );
        glDisable( GL_DEPTH_TEST );
        glDisable( GL_CULL_FACE );
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
        glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );
              glDisable( GL_FOG );
        break;
    case GAUGE_BARS:
        glEnable( GL_TEXTURE_2D );
        glDisable( GL_DEPTH_TEST );
        glDisable( GL_CULL_FACE );
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
        glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glEnable( GL_TEXTURE_GEN_S );
              glEnable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );

              glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
              glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
        break;

    case TEXFONT:
        glEnable( GL_TEXTURE_2D );
        glDisable( GL_DEPTH_TEST );
        glDisable( GL_CULL_FACE );
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
        glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
        glEnable( GL_LINE_SMOOTH );
              glDepthFunc( GL_LESS );
        break;

    case TEXT:
        glDisable( GL_TEXTURE_2D );
        glDisable( GL_DEPTH_TEST );
        glDisable( GL_CULL_FACE );
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
        glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );
        break;

    case SPLASH_SCREEN:
        glDisable( GL_TEXTURE_2D );
        glDisable( GL_DEPTH_TEST );
        glDisable( GL_CULL_FACE );
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
        glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );
        break;

    case COURSE:
              glEnable( GL_TEXTURE_2D );
              glEnable( GL_DEPTH_TEST );
              glEnable( GL_CULL_FACE );
              glEnable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
              glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glEnable( GL_TEXTURE_GEN_S );
              glEnable( GL_TEXTURE_GEN_T );
              glEnable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LEQUAL );

              glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
              glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
              break;

    case TREES:
              glEnable( GL_TEXTURE_2D );
              glEnable( GL_DEPTH_TEST );
        glDisable( GL_CULL_FACE );
              glEnable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
        glEnable( GL_ALPHA_TEST );
              glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );

        glAlphaFunc( GL_GEQUAL, 0.5 );
        break;
        
    case PARTICLES:
        glEnable( GL_TEXTURE_2D );
              glEnable( GL_DEPTH_TEST );
        glDisable( GL_CULL_FACE );
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glEnable( GL_ALPHA_TEST );
        glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );

        glAlphaFunc( GL_GEQUAL, 0.5 );
        break;    
        
    case PARTICLE_SHADOWS:
        glDisable( GL_TEXTURE_2D );
              glEnable( GL_DEPTH_TEST );
        glDisable( GL_CULL_FACE );
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
        glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );
        break;

    case SKY:
              glEnable( GL_TEXTURE_2D );
              glDisable( GL_DEPTH_TEST );
              glDisable( GL_CULL_FACE ); 
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
              glDisable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_FALSE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );
              glDepthFunc( GL_ALWAYS );
              break;
       
    case FOG_PLANE:
              glDisable( GL_TEXTURE_2D );
              glEnable( GL_DEPTH_TEST );
              glDisable( GL_CULL_FACE ); 
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
              glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );
              break;

    case TUX:
        glDisable( GL_TEXTURE_2D );
              glEnable( GL_DEPTH_TEST );
              glEnable( GL_CULL_FACE );
        glEnable( GL_LIGHTING );
              glEnable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
              glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );
        break;

    case TUX_SHADOW:
              if(getparam_stencil_buffer()){
                     glDisable( GL_TEXTURE_2D );
                     glEnable( GL_DEPTH_TEST );
                     glDisable( GL_CULL_FACE );
                     glDisable( GL_LIGHTING );
                     glDisable( GL_NORMALIZE );
                     glDisable( GL_ALPHA_TEST );
                     glEnable( GL_BLEND );
                     glEnable( GL_STENCIL_TEST );
                     glDisable( GL_COLOR_MATERIAL );
                     glDepthMask( GL_FALSE );
                     glShadeModel( GL_SMOOTH );
                     glDepthFunc( GL_LESS );
                     glStencilFunc( GL_EQUAL, 0, ~0 );
                     glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
              }else{
                     glDisable( GL_TEXTURE_2D );
                     glEnable( GL_DEPTH_TEST );
                     glEnable( GL_CULL_FACE );
                     glDisable( GL_LIGHTING );
                     glDisable( GL_NORMALIZE );
                     glDisable( GL_ALPHA_TEST );
                     glEnable( GL_BLEND );
                     glDisable( GL_STENCIL_TEST );
                     glDisable( GL_COLOR_MATERIAL );
                     glDepthMask( GL_TRUE );
                     glShadeModel( GL_SMOOTH );
                     glDepthFunc( GL_LESS );
              }
              break;

    case TRACK_MARKS:
              glEnable( GL_TEXTURE_2D );
              glEnable( GL_DEPTH_TEST );
              glDisable( GL_CULL_FACE );
              glEnable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glDisable( GL_ALPHA_TEST );
              glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_COLOR_MATERIAL );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDepthMask( GL_FALSE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LEQUAL );
              break;

    case OVERLAYS:
        glEnable( GL_TEXTURE_2D );
        glDisable( GL_DEPTH_TEST );
        glDisable( GL_CULL_FACE );
              glDisable( GL_LIGHTING );
              glDisable( GL_NORMALIZE );
              glEnable( GL_ALPHA_TEST );
        glEnable( GL_BLEND );
              glDisable( GL_STENCIL_TEST );
              glDisable( GL_TEXTURE_GEN_S );
              glDisable( GL_TEXTURE_GEN_T );
              glDisable( GL_COLOR_MATERIAL );
              glDepthMask( GL_TRUE );
              glShadeModel( GL_SMOOTH );
              glDepthFunc( GL_LESS );

        glAlphaFunc( GL_GEQUAL, 0.5 );
        break;

    default:
       code_not_reached();
    } 
} 

Here is the caller graph for this function:


Variable Documentation

PFNGLLOCKARRAYSEXTPROC glLockArraysEXT_p

Definition at line 394 of file gl_util.cpp.

PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT_p

Definition at line 395 of file gl_util.cpp.