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

glsl_perlin_test.C

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

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