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

glsl_hatching.H

Go to the documentation of this file.
00001 /**********************************************************************
00002  * glsl_hatching.H:
00003  **********************************************************************/
00004 #ifndef GLSL_HATCHING_H_IS_INCLUDED
00005 #define GLSL_HATCHING_H_IS_INCLUDED
00006 
00007 #include "glsl_paper.H"
00008 
00009 /**********************************************************************
00010  * GLSLHatching:
00011  *
00012  *  Simple image-space hatching via GLSL fragment program
00013  *
00014  **********************************************************************/
00015 class GLSLHatching : public GLSLPaperShader {
00016  public:
00017    //******** MANAGERS ********
00018    GLSLHatching(Patch* patch = 0);
00019    
00020    virtual ~GLSLHatching();
00021 
00022    //******** RUN-TIME TYPE ID ********
00023    DEFINE_RTTI_METHODS3("GLSL Hatching", GLSLHatching*, BasicTexture, CDATA_ITEM*);
00024 
00025    //******** ACCESSORS ********
00026    void set_style(int l, int l2, int l3) {
00027       _style[0] = l; 
00028       _style[1] = l2; 
00029       _style[2] = l3; 
00030    }
00031 
00032    //******** GLSLShader VIRTUAL METHODS ********
00033    void set_tone_shader(GTexture* g);
00034 
00035    // using a static variable for program, so all GLSLHatching
00036    // instances share the same program:
00037    virtual GLuint& program() { return _program; }
00038    virtual bool&  did_init() { return _did_init; }
00039 
00040    virtual bool get_variable_locs();
00041 
00042    virtual bool set_uniform_variables() const;
00043 
00044    virtual void set_gl_state(GLbitfield mask=0) const;
00045 
00046    // ******** GTexture VIRTUAL METHODS ********
00047    virtual ref_img_t use_ref_image();
00048    virtual int       draw_tex_mem_ref();
00049 
00050    // Returns a list of the slave gtextures of this class
00051    virtual GTexture_list gtextures() const;
00052 
00053    //******** DATA_ITEM VIRTUAL METHODS ********
00054    virtual DATA_ITEM  *dup() const { return new GLSLHatching; }
00055 
00056  protected:
00057    // shader used to draw the tone reference image:
00058    GTexture*     _tone_shader;
00059 
00060    GLint         _style[4];
00061 
00062    static GLuint _program;  // GLSL program shared by all instances
00063    static bool   _did_init; // tells whether initialization attempt was made
00064 
00065    // tone map variables:
00066    static GLint  _tone_tex_loc;
00067    static GLint  _width_loc;
00068    static GLint  _height_loc;
00069 
00070    static GLint  _style_loc;  
00071 
00072    //******** VIRTUAL METHODS ********
00073 
00074    // GLSL vertex shader name
00075    virtual str_ptr vp_filename() { return vp_name("hatching"); }
00076 
00077    // GLSL fragment shader name
00078    virtual str_ptr fp_filename() { return fp_name("hatching"); }
00079 };
00080 
00081 #endif // GLSL_HATCHING_H_IS_INCLUDED
00082 
00083 // end of file glsl_hatching.H

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