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