Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

glsl_halo.C

Go to the documentation of this file.
00001 /*****************************************************************
00002  * glsl_halo.C
00003  *****************************************************************/
00004 #include "gtex/gl_extensions.H"
00005 #include "glsl_halo.H"
00006 
00007 static bool debug = Config::get_var_bool("DEBUG_GLSL_HALO", false);
00008 
00009 /**********************************************************************
00010  * GLSLHaloShader:
00011  *
00012  *   Does Halo shading in GLSL.
00013  **********************************************************************/
00014 GLuint          GLSLHaloShader::_program = 0;
00015 GLint           GLSLHaloShader::_pixel_width_loc = -1;
00016 //GLint           GLSLHaloShader::_distance_loc = -1;
00017 bool            GLSLHaloShader::_did_init = false;
00018 GLSLHaloShader* GLSLHaloShader::_instance(0);
00019 
00020 
00021 GLSLHaloShader::GLSLHaloShader(Patch* p) :
00022    GLSLToonShader(p)
00023 {
00024 
00025    set_tex(GtexUtil::toon_name(
00026       Config::get_var_str("GLSL_HALO_FILENAME","halo_white.png")
00027       ));
00028 }
00029 
00030 GLSLHaloShader* 
00031 GLSLHaloShader::get_instance()
00032 {
00033    if (!_instance) {
00034       _instance = new GLSLHaloShader();
00035       assert(_instance);
00036    }
00037    return _instance;
00038 }
00039 
00040 
00041 bool 
00042 GLSLHaloShader::get_variable_locs()
00043 {
00044    // gets HaloShader-specific uniform variable locations (from "halo2.vp")
00045 
00046 
00047    get_uniform_loc("pixel_width", _pixel_width_loc);
00048 //   get_uniform_loc("camera_distance", _distance_loc);
00049 
00050    // other variables here as needed...
00051 
00052    return GLSLToonShader::get_variable_locs();
00053 }
00054 
00055 bool
00056 GLSLHaloShader::set_uniform_variables() const
00057 {
00058    // send uniform variable values to the program
00059 
00060 
00061    // The following 7 lines are used when halo size is computed by distance
00062    // rather than in terms of pixels.  It is retained but commented out in case
00063    // somebody decides at any point that this was a good idea.
00064 //   Wpt e = VIEW::peek()->eye();
00065 //   Wpt c = _patch->mesh()->get_bb().center();
00066 //   GLfloat distance;
00067 //   distance = e.dist(c);
00068 //   distance = (distance < 20 ? 20 : distance);
00069 //   distance = (distance > 900 ? 900 : distance);
00070 //   glUniform1f(_distance_loc, distance);
00071 
00072    // declare array to hold info, get info from viewport; what we want is
00073    // vp[2]: the width of the screen in pixels
00074    GLint vp[4];
00075    glGetIntegerv(GL_VIEWPORT, vp);
00076 
00077    glUniform1f(_pixel_width_loc, vp[2]/2);
00078 
00079   
00080    return GLSLToonShader::set_uniform_variables();
00081 }
00082 
00083 void GLSLHaloShader::set_gl_state(GLbitfield mask) const
00084 {
00085    GLSLShader::set_gl_state(mask);
00086 
00087    glEnable(GL_BLEND);
00088    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00089 }
00090 
00091 
00092 
00093 // end of file glsl_halo.C

Generated on Mon Sep 18 11:39:30 2006 for jot by  doxygen 1.4.4