KGLLib
program.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef KGLLIB_PROGRAM_H
00019 #define KGLLIB_PROGRAM_H
00020
00021 namespace KGLLib
00022 {
00023 class Shader;
00024 }
00025 class QString;
00026 template<class T> class QList;
00027 template<class K, class V> class QHash;
00028
00029 #include "kgllib.h"
00030 #include <Eigen/Core>
00031
00032 namespace KGLLib
00033 {
00034
00120 class KGLLIB_EXPORT Program
00121 {
00122 public:
00128 Program();
00133 Program(const QList<Shader*>& shaders);
00139 Program(const QString& vertexshaderfile, const QString& fragmentshaderfile);
00143 virtual ~Program();
00144
00148 void addShader(Shader* shader);
00152 void addShaders(const QList<Shader*>& shaders);
00153
00160 virtual bool link();
00161
00170 bool isValid() const { return mValid; }
00178 char* linkLog() const { return mLinkLog; }
00179
00186 virtual void bind() const;
00195 virtual void unbind() const;
00196
00197 int uniformLocation(const QString& name);
00198 int uniformLocation(const char* name);
00199
00200 int attributeLocation(const QString& name);
00201 int attributeLocation(const char* name);
00202
00203 void invalidateLocations();
00204
00214 bool setUniform(const char* name, float value);
00218 bool setUniform(const char* name, Eigen::Vector2f value);
00222 bool setUniform(const char* name, Eigen::Vector3f value);
00226 bool setUniform(const char* name, Eigen::Vector4f value);
00230 bool setUniform(const char* name, int value);
00231
00235 GLuint glId() const { return mGLId; }
00236
00237 protected:
00238 void init();
00239
00240 protected:
00241 GLuint mGLId;
00242 bool mValid;
00243 char* mLinkLog;
00244 QHash<QString, int>* mUniformLocations;
00245 QHash<QString, int>* mAttributeLocations;
00246 };
00247
00248 }
00249
00250 #endif