gl_glsl_shader.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Kutumov Alexey                                  *
00003  *   ru.pixel@gmail.com                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00033 #ifndef __gl_glsl_shader__header__
00034 #define __gl_glsl_shader__header__
00035 
00036 #include "gpucalc/shader.h"
00037 
00038 #include <GL/glew.h>
00039 
00040 namespace gpucalc
00041 {
00042  
00043  const char _GLGLSLShaderClassName [] = "GLGLSLShader";
00044  
00045  class _GpuCalcPrivate GLGLSLShader: public Shader
00046  {
00047 
00048   OBJ_DISABLE_COPY(GLGLSLShader)
00049 
00050 
00051   friend class GLGLSLShaderSystem;
00052 
00053 
00054   public:
00055    GLGLSLShader(const std::string & ShaderName, ShaderSystem * system);
00056 
00057 
00058    ~GLGLSLShader();
00059 
00060 
00061    void setSource(const std::string & ShaderSource);
00062 
00063 
00064    std::string getSource() const
00065    {
00066     return mShaderSource;
00067    }
00068 
00069 
00073    void addUniform(Uniform * uniform);
00074 
00075 
00076    void removeUniform(Uniform * uniform);
00077 
00078 
00079    void compile(const std::string & Parameters = std::string());
00080 
00081 
00082    bool isCompiled() const
00083    {
00084     return mIsCompiled;
00085    }
00086 
00087 
00088    void validate();
00089 
00090 
00091    void preCompute();
00092 
00093 
00094    bool isDebugEnabled() const
00095    {
00096     return mIsDebug;
00097    }
00098 
00099 
00100    std::string getLanguageID() const
00101    {
00102     return "glsl";
00103    }
00104 
00105 
00106   private:
00107    GLhandleARB mGLSLProgramID;
00108 
00109 
00110    GLhandleARB mGLSLFragmentShaderID;
00111 
00112 
00113    GLint mMultiTextureNumber;
00114 
00115 
00116    typedef std::list<Uniform *> UniformVector;
00117    UniformVector mUniformVector;
00118 
00119 
00120    bool mIsCompiled;
00121 
00122 
00123    bool mIsDebug;
00124 
00125 
00126    std::string mShaderSource;
00127 
00128 
00129    std::string mShaderCompilerParams;
00130 
00131 
00132    void compileStatus();
00133 
00134 
00135    void linkStatus();
00136 
00137 
00138    void ShaderInfoLog();
00139 
00140 
00141    void ProgramInfoLog();
00142 
00143 
00144    GLint getUniformLocation(const std::string & Name);
00145 
00146 
00147    void setUniformVariable(Uniform * uniform);
00148 
00149 
00150    void setUniformSampler(Uniform * uniform);
00151  };
00152 }
00153 
00154 #endif

Generated on Thu Mar 5 22:36:42 2009 for gpucalc by  doxygen 1.5.6