gl_Cg_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_Cg_shader__header__
00034 #define __gl_Cg_shader__header__
00035 
00036 #include "gpucalc/shader.h"
00037 
00038 #include <Cg/cgGL.h>
00039 
00040 namespace gpucalc
00041 {
00042 
00043  const char _GLCgShaderClassName [] = "GLCgShader";
00044 
00045 
00046  class _GpuCalcPrivate GLCgShader: public Shader
00047  {
00048 
00049 
00050   OBJ_DISABLE_COPY(GLCgShader)
00051 
00052 
00053   friend class GLCgShaderSystem;
00054 
00055 
00056   public:
00057    GLCgShader(const std::string & ShaderName, CGcontext CgContext, CGprofile CgProfile, ShaderSystem * system);
00058 
00059 
00060   ~GLCgShader();
00061 
00062   
00063   void setSource(const std::string & ShaderSource);
00064 
00065 
00066   std::string getSource() const
00067   {
00068    return mShaderSource;
00069   }
00070 
00071 
00075   void addUniform(Uniform * uniform);
00076 
00077 
00078   void removeUniform(Uniform * uniform);
00079 
00080 
00081   void compile(const std::string & Parameters = std::string());
00082 
00083 
00084   bool isCompiled() const
00085   {
00086    return mIsCompiled;
00087   }
00088 
00089 
00090   void validate();
00091 
00092 
00093   void preCompute();
00094 
00095 
00096   bool isDebugEnabled() const
00097   {
00098    return mIsDebug;
00099   }
00100 
00101 
00102   std::string getLanguageID() const
00103   {
00104    return "Cg";
00105   }
00106 
00107 
00108   private:
00109 
00110 
00112    CGcontext mCgContextID;
00113 
00114 
00115    CGprofile mCgFragmentProfileID;
00116 
00117 
00118    CGprogram mCgFragmentProgramID;
00119 
00120 
00121    bool mIsCompiled;
00122 
00123 
00124    bool mIsDebug;
00125 
00126 
00127    void setUniformVariable(Uniform * uniform);
00128 
00129 
00130    void setUniformSampler(Uniform * uniform);
00131 
00132 
00133    std::string mShaderSource;
00134 
00135 
00136    std::string mShaderCompilerParams;
00137 
00138 
00139    typedef std::list<Uniform *> UniformVector;
00140    UniformVector mUniformVector;
00141  };
00142 }
00143 
00144 #endif

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