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

glsl_toon_halo.C

Go to the documentation of this file.
00001 /*****************************************************************
00002  * glsl_toon_halo.C
00003  *****************************************************************/
00004 #include "gtex/gl_extensions.H"
00005 #include "glsl_toon_halo.H"
00006 
00007 static bool debug = Config::get_var_bool("DEBUG_GLSL_TOON", false);
00008 
00009 /**********************************************************************
00010  * GLSLToonShaderHalo:
00011  *
00012  *   Does 1D Toon shading in GLSL.
00013  **********************************************************************/
00014 GLSLToonShaderHalo::GLSLToonShaderHalo(Patch* p) :
00015    GLSLShader(p, new VertNormStripCB)
00016 {
00017    set_tex(GtexUtil::toon_name(
00018       Config::get_var_str("HALO_TEX","halo_white2.png")
00019       ));
00020 }
00021 
00022 void 
00023 GLSLToonShaderHalo::set_tex(Cstr_ptr& filename)
00024 {
00025    // Set the name of the texture to use
00026    if (_tex) {
00027       _tex->set_texture(filename);
00028    } else {
00029       _tex = new TEXTUREgl(filename);
00030       assert(_tex);
00031    }
00032 }
00033 
00034 void
00035 GLSLToonShaderHalo::init_textures()
00036 {
00037    // no-op after the first time:
00038    if (!load_texture(_tex))
00039       return;
00040 
00041    // set parameters
00042    // XXX - we're calling this every frame, but it's light-weight
00043    _tex->set_wrap_s(GL_CLAMP_TO_EDGE);
00044    _tex->set_wrap_t(GL_CLAMP_TO_EDGE);  
00045 }
00046 
00047 void
00048 GLSLToonShaderHalo::activate_textures()
00049 {
00050    activate_texture(_tex);      // GL_ENABLE_BIT
00051 }
00052 
00053 bool 
00054 GLSLToonShaderHalo::get_variable_locs()
00055 {
00056    if (!get_uniform_loc("toon_tex", _tex_loc))
00057       return false;
00058 
00059    // other variables here as needed...
00060    return true;
00061 }
00062 
00063 bool
00064 GLSLToonShaderHalo::set_uniform_variables() const
00065 {
00066    // send values to the program
00067 
00068    glUniform1i(_tex_loc, _tex->get_tex_unit() - GL_TEXTURE0);
00069    return true;
00070 }
00071 
00072 // end of file glsl_toon_halo.C

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