49 #include <ACG/Config/ACGDefines.hh> 50 #include <ACG/Math/VectorT.hh> 51 #include <ACG/Math/GLMatrixT.hh> 52 #include <ACG/GL/gl.hh> 56 #include <QStringList> 65 #define GLSL_MAX_LOGSIZE 16384 67 typedef std::list<std::string> StringList;
74 explicit Shader(GLenum shaderType);
76 void setSource(
const StringList& source);
77 void setSource(
const QStringList& source);
80 bool compile(
bool verbose =
true);
136 #ifdef GL_ARB_tessellation_shader 140 class ACGDLLEXPORT TessControlShader :
public Shader {
144 virtual ~TessControlShader();
147 typedef TessControlShader* PtrTessControlShader;
148 typedef const TessControlShader* PtrConstTessControlShader;
154 class ACGDLLEXPORT TessEvaluationShader :
public Shader {
157 TessEvaluationShader();
158 virtual ~TessEvaluationShader();
161 typedef TessEvaluationShader* PtrTessEvaluationShader;
162 typedef const TessEvaluationShader* PtrConstTessEvaluationShader;
164 #endif // GL_ARB_tessellation_shader 180 int maxUniformBlocks_;
181 int maxTextureImageUnits_;
182 int maxImageUniforms_;
183 int maxSharedMemorySize_;
184 int maxUniformComponents_;
185 int maxAtomicCounterBufs_;
186 int maxAtomicCounters_;
187 int maxCombinedUniformComponents_;
188 int maxWorkGroupInvocations_;
189 int maxWorkGroupCount_[3];
190 int maxWorkGroupSize_[3];
193 static const Caps& caps();
198 static bool capsInitialized_;
225 void attach(PtrConstShader _shader);
226 void detach(PtrConstShader _shader);
237 int getAttributeLocation(
const char *_name);
238 int getUniformLocation(
const char *_name);
239 int getFragDataLocation(
const char* _name);
241 void bindAttributeLocation(
unsigned int _index,
const char *_name);
242 void bindFragDataLocation(
unsigned int _index,
const char *_name);
252 void setUniform(
const char *_name, GLint _value);
253 void setUniform(
const char *_name,
const ACG::Vec2i &_value);
254 void setUniform(
const char *_name,
const ACG::Vec3i &_value);
255 void setUniform(
const char *_name,
const ACG::Vec4i &_value);
257 void setUniform(
const char *_name, GLuint _value);
258 void setUniform(
const char *_name,
const ACG::Vec2ui &_value);
259 void setUniform(
const char *_name,
const ACG::Vec3ui &_value);
260 void setUniform(
const char *_name,
const ACG::Vec4ui &_value);
262 void setUniform(
const char *_name, GLfloat _value);
263 void setUniform(
const char *_name,
const ACG::Vec2f &_value);
264 void setUniform(
const char *_name,
const ACG::Vec3f &_value);
265 void setUniform(
const char *_name,
const ACG::Vec4f &_value);
268 void setUniform(
const char *_name,
const ACG::GLMatrixf &_value,
bool _transposed =
false);
269 void setUniformMat3(
const char *_name,
const ACG::GLMatrixf &_value,
bool _transposed =
false);
273 void setUniform(
const char *_name,
const GLint *_values,
int _count);
274 void setUniform(
const char *_name,
const GLfloat *_values,
int _count);
275 void setUniform(
const char *_name,
const ACG::Vec2f *_values,
int _count);
276 void setUniform(
const char *_name,
const ACG::Vec3f *_values,
int _count);
277 void setUniform(
const char *_name,
const ACG::Vec4f *_values,
int _count);
278 void setUniform(
const char *_name,
int _index,
bool _value);
280 void setUniform(
const char *_name,
int _index,
int _value);
281 void setUniform(
const char *_name,
int _index,
float _value);
293 GLuint getUniformBlockIndex(
const char *_name);
295 void setUniformBlockBinding(GLuint _index,
int _binding);
296 void setUniformBlockBinding(
const char *_name,
int _binding);
298 int getUniformBlockSize(GLuint _index);
299 int getUniformBlockSize(
const char *_name);
301 void getUniformBlockOffsets(
int _numUniforms,
const char **_names,
int *_outOffsets);
312 void setGeometryInputType(GLint _type);
313 void setGeometryOutputType(GLint _type);
314 void setGeometryVertexCount(GLint _numVerticesOut);
331 GLuint getProgramId();
335 std::list<PtrConstShader> m_linkedShaders;
346 GLSL::StringList ACGDLLEXPORT
loadShader(
const char *filename,
const GLSL::StringList *macros = 0,
bool appendNewLineChar =
true, GLSL::StringList *outIncludes = 0);
361 const char *fragmentShaderFile,
362 const GLSL::StringList *macros = 0,
363 bool verbose =
true);
371 const char *geometryShaderFile,
372 const char *fragmentShaderFile,
373 const GLSL::StringList *macros = 0,
374 bool verbose =
true);
382 const char *tessControlShaderFile,
383 const char *tessEvaluationShaderFile,
384 const char *geometryShaderFile,
385 const char *fragmentShaderFile,
386 const GLSL::StringList *macros = 0,
387 bool verbose =
true);
395 const GLSL::StringList *macros = 0,
396 bool verbose =
true);
399 #endif // GLSLSHADER_H
GLSL::PtrFragmentShader loadFragmentShader(const char *name, const GLSL::StringList *macros, bool verbose)
Loads, compiles and installs a new vertex shader.
GLSL::PtrProgram loadComputeProgram(const char *computeShaderFile, const GLSL::StringList *macros, bool verbose)
GLSL::StringList loadShader(const char *filename, const GLSL::StringList *macros, bool appendNewLineChar, GLSL::StringList *outIncludes)
Loads the shader source.
GLSL::PtrShader loadTessControlShader(const char *name, const GLSL::StringList *macros, bool verbose)
Loads, compiles and installs a new tessellation control shader.
GLSL::PtrProgram loadProgram(const char *vertexShaderFile, const char *tessControlShaderFile, const char *tessEvaluationShaderFile, const char *geometryShaderFile, const char *fragmentShaderFile, const GLSL::StringList *macros, bool verbose)
This namespace contains all the classes and functions for handling GLSL shader and program objects...
GLSL::PtrShader loadTessEvaluationShader(const char *name, const GLSL::StringList *macros, bool verbose)
Loads, compiles and installs a new tessellation evaluation shader.
GLSL::PtrComputeShader loadComputeShader(const char *name, const GLSL::StringList *macros, bool verbose)
Loads, compiles and installs a new compute shader.
GLSL::PtrVertexShader loadVertexShader(const char *name, const GLSL::StringList *macros, bool verbose)
Loads, compiles and installs a new vertex shader.
GLSL::PtrGeometryShader loadGeometryShader(const char *name, const GLSL::StringList *macros, bool verbose)
Loads, compiles and installs a new vertex shader.
A generic shader base class.