GLSLShaderSetup.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #if !defined(__INCLUDE_GLSLShaderSetuph_INCLUDE__)
00022 #define __INCLUDE_GLSLShaderSetuph_INCLUDE__
00023 
00024 #include <GLSL/GLSLShader.h>
00025 #include <GLSL/GLSLProgram.h>
00026 
00027 class GLSLShaderSetup
00028 {
00029 public:
00030         /// create shader setup of two shaders
00031         GLSLShaderSetup(
00032                 const std::string &filename_vshader,
00033                 const std::string &filename_fshader,
00034                 const GLSLShader::defines_list& dl = GLSLShader::defines_list());
00035         ~GLSLShaderSetup();
00036 
00037         /// use this setup
00038         void use() const { prog_.use(); }
00039 
00040         /// use fixed function pipeline instead of particular setup
00041         static void use_fixed() { GLSLProgram::use_fixed(); }
00042 
00043         /// set up texture for a particular shader name
00044         void set_gl_texture(GLTexture &tex, const char *texname, unsigned texunitnr) const 
00045         {
00046                 prog_.set_gl_texture(tex, texname, texunitnr);
00047         }
00048         void set_gl_texture(GLShadowFrameBuffer &tex, const char *texname, unsigned texunitnr) const
00049         {
00050                 prog_.set_gl_texture(tex, texname, texunitnr);
00051         }
00052         void set_gl_texture_unit(const char *texname, unsigned texunitnr) const
00053         {
00054                 prog_.set_gl_texture_unit(texname, texunitnr);
00055         }
00056 
00057         /// set uniform variable
00058         void set_uniform(const char *name, const Vector& value) const 
00059         {
00060                 prog_.set_uniform(name, value);
00061         }
00062         void set_uniform(const char *name, const float value) const
00063         {
00064                 prog_.set_uniform(name, value);
00065         }
00066 
00067         /// get vertex attribute index
00068         unsigned get_vertex_attrib_index(const char *name) const 
00069         {
00070                 return prog_.get_vertex_attrib_index(name);
00071         }
00072 
00073 protected:
00074         GLSLShader vs_, fs_;
00075         GLSLProgram prog_;
00076 
00077 private:
00078         GLSLShaderSetup(const GLSLShaderSetup&);
00079         GLSLShaderSetup& operator= (const GLSLShaderSetup&);
00080 };
00081 
00082 #endif // __INCLUDE_GLSLShaderSetuph_INCLUDE__

Generated on Mon Feb 16 15:14:45 2009 for Scorched3D by  doxygen 1.5.3