glc_shader.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
00019
00020
00021
00022
00024
00025 #ifndef GLC_SHADER_H_
00026 #define GLC_SHADER_H_
00027
00028 #include "../glc_global.h"
00029 #include <QGLShader>
00030 #include <QGLShaderProgram>
00031 #include <QStack>
00032 #include <QFile>
00033 #include <QMutex>
00034 #include <QString>
00035
00036 #include "../glc_config.h"
00037
00040
00047
00048 class GLC_LIB_EXPORT GLC_Shader
00049 {
00051
00053
00054 public:
00056 GLC_Shader();
00057
00059 GLC_Shader(QFile&, QFile&);
00060
00062 GLC_Shader(const GLC_Shader&);
00063
00065 ~GLC_Shader();
00067
00069
00071
00072 public:
00074 inline GLuint id() const
00075 {return m_ProgramShaderId;}
00076
00078 inline bool isUsable() const
00079 {return m_ProgramShader.isLinked();}
00080
00082 bool canBeDeleted() const;
00083
00085 inline QString name() const
00086 {return m_Name;}
00087
00089 inline QGLShaderProgram* programShaderHandle()
00090 {return &m_ProgramShader;}
00091
00093 static int shaderCount();
00094
00096 static bool asShader(GLC_uint shadingGroupId);
00097
00099
00100 static GLC_Shader* shaderHandle(GLC_uint shadingGroupId);
00101
00103 static bool hasActiveShader();
00104
00106
00107 static GLC_Shader* currentShaderHandle();
00109
00111
00113
00114 public:
00116 void setVertexAndFragmentShader(QFile&, QFile&);
00117
00119
00120 void replaceShader(const GLC_Shader&);
00121
00123 inline GLC_Shader& operator=(const GLC_Shader& shader)
00124 {
00125 replaceShader(shader);
00126 return *this;
00127 }
00128
00130 inline void setName(const QString& name)
00131 {m_Name= name;}
00132
00134
00136
00138
00139 public:
00141
00142 void use();
00143
00145
00146 static bool use(GLuint ShadingGroupId);
00147
00149 static void unuse();
00150
00152
00153 void createAndCompileProgrammShader();
00154
00156 void deleteShader();
00158
00160
00162 private:
00164 static QStack<GLC_uint> m_ShadingGroupStack;
00165
00167 static GLC_uint m_CurrentShadingGroupId;
00168
00170 static QHash<GLC_uint, GLC_Shader*> m_ShaderProgramHash;
00171
00173 QGLShader m_VertexShader;
00174
00176 QGLShader m_FragmentShader;
00177
00179 QGLShaderProgram m_ProgramShader;
00180
00182 GLC_uint m_ProgramShaderId;
00183
00185 QString m_Name;
00186
00187 };
00188
00189 #endif