00001 /************************************************************************** 00002 * halftone_shader.H 00003 *************************************************************************/ 00004 00005 #ifndef HALFTONE_SHADER_IS_INCLUDED 00006 #define HALFTONE_SHADER_IS_INCLUDED 00007 00008 #include "glsl_shader.H" 00009 00010 // --compile_time; 00011 class GLSLToonShader; 00012 00013 class HalftoneShader : public GLSLShader { 00014 public: 00015 // ******** MANAGERS ******** 00016 HalftoneShader(Patch* patch = 0); 00017 00018 void set_style(int s) { _style = s; } 00019 // ******** RUN-TIME TYPE ID ******** 00020 DEFINE_RTTI_METHODS3("Halftone Shader", 00021 HalftoneShader*, BasicTexture, CDATA_ITEM*); 00022 00023 // ******** GLSLShader VIRTUAL METHODS ******** 00024 00025 // Called in init(), subclasses can query and store the 00026 // "locations" of uniform and attribute variables here. 00027 // Base class doesn't use any variables, so it's a no-op. 00028 virtual bool get_variable_locs(); 00029 00030 // The following are called in draw(): 00031 00032 // Send values of uniform variables to the shader. 00033 virtual bool set_uniform_variables() const; 00034 00035 // Initialize textures, if any: 00036 virtual void init_textures(); 00037 00038 virtual void set_gl_state(GLbitfield mask=0) const; 00039 00040 // Activate textures, if any: 00041 virtual void activate_textures(); 00042 00043 // Calls glPopAttrib(): 00044 //virtual void restore_gl_state() const; 00045 00046 /** Returns a list of the slave gtextures of this class */ 00047 virtual GTexture_list gtextures() const; 00048 00049 // ******** GTexture VIRTUAL METHODS ******** 00050 virtual ref_img_t use_ref_image(); 00051 virtual int draw_tex_mem_ref(); 00052 00053 // ******** DATA_ITEM VIRTUAL METHODS ******** 00054 virtual DATA_ITEM *dup() const { return new HalftoneShader; } 00055 00056 private: 00057 00058 // ******** Member Variables ******** 00059 GLSLToonShader* m_toon_tone_shader; 00060 TEXTUREglptr m_texture; 00061 TEXTUREglptr _perlin; 00062 GLint _lod_loc; 00063 GLint m_origin_loc; 00064 GLint m_u_vec_loc; 00065 GLint m_v_vec_loc; 00066 GLint m_tex_loc; 00067 GLint m_width; 00068 GLint m_height; 00069 GLint _style_loc; 00070 int _style; 00071 GLint _perlin_loc; // "location" of the 00072 Perlin* _perlin_generator; //pointer to an instance of the 00073 //perlin texture generator 00074 00075 // ******** VIRTUAL METHODS ******** 00076 00077 // Return the names of the halftone GLSL shader programs: 00078 virtual str_ptr vp_filename() { return vp_name("halftone"); } 00079 virtual str_ptr fp_filename() { return fp_name("halftone"); } 00080 }; 00081 00082 #endif // HALFTONE_SHADER_IS_INCLUDED 00083 00084 // End of file halftone_shader.H