Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
GLSL.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef GLSL_INCLUDE_ONCE
33 #define GLSL_INCLUDE_ONCE
34 
36 #include <vlCore/glsl_math.hpp>
38 #include <vlCore/String.hpp>
39 
40 namespace vl
41 {
42  class Uniform;
43 
44  //------------------------------------------------------------------------------
45  // GLSLShader
46  //------------------------------------------------------------------------------
51  {
53 
54 
55  static String processSource( const String& source );
56 
57  public:
58  GLSLShader();
59 
60  GLSLShader(EShaderType type, const String& source_or_path);
61 
62  ~GLSLShader();
63 
64  void setType(EShaderType type) { mType = type; }
65 
66  EShaderType type() const { return mType; }
67 
69  void setSource( const String& source_or_path );
70 
72  const std::string& source() const { return mSource; }
73 
75  void setPath(const String& path) { mPath = path; }
76 
78  const String& path() const { return mPath; }
79 
81  bool reload();
82 
84  std::string getShaderSource() const;
85 
88  bool compile();
89 
92  bool compileStatus() const;
93 
95  String infoLog() const;
96 
98  void createShader();
99 
101  void deleteShader();
102 
104  unsigned int handle() const { return mHandle; }
105 
106  protected:
108  std::string mSource;
110  unsigned int mHandle;
111  bool mCompiled;
112  };
113  //------------------------------------------------------------------------------
118  {
120 
121  public:
125  {
126  #ifndef NDEBUG
127  if (mObjectName.empty())
128  mObjectName = className();
129  #endif
130  }
131  };
132  //------------------------------------------------------------------------------
137  {
139 
140  public:
143  {
144  #ifndef NDEBUG
145  if (mObjectName.empty())
146  mObjectName = className();
147  #endif
148  }
149  };
150  //------------------------------------------------------------------------------
155  {
157 
158  public:
161  {
162  #ifndef NDEBUG
163  if (mObjectName.empty())
164  mObjectName = className();
165  #endif
166  }
167  };
168  //------------------------------------------------------------------------------
173  {
175 
176  public:
179  {
180  #ifndef NDEBUG
181  if (mObjectName.empty())
182  mObjectName = className();
183  #endif
184  }
185  };
186  //------------------------------------------------------------------------------
191  {
193 
194  public:
197  {
198  #ifndef NDEBUG
199  if (mObjectName.empty())
200  mObjectName = className();
201  #endif
202  }
203  };
204  //------------------------------------------------------------------------------
205  // GLSLProgram
206  //------------------------------------------------------------------------------
234  {
236 
237  // applyUniform
238  friend class Renderer;
239  public:
241  GLSLProgram();
242 
244  ~GLSLProgram();
245 
247  virtual ERenderState type() const { return RS_GLSLProgram; }
248 
249  virtual ref<RenderState> clone() const
250  {
251  ref<GLSLProgram> rs = new GLSLProgram;
252  *rs = *this;
253  return rs;
254  }
255 
257  bool reload();
258 
262  void createProgram();
263 
266  void deleteProgram();
267 
273  unsigned int handle() const { return mHandle; }
274 
276  void apply(int index, const Camera*, OpenGLContext* ctx) const;
277 
283  bool linkProgram(bool force_relink = false);
284 
285  bool linkStatus() const;
286 
288  bool linked() const { return mHandle && !mScheduleLink; }
289 
291  void scheduleRelinking() { mScheduleLink = true; }
292 
298  bool attachShader(GLSLShader* shader);
299 
301  bool detachShader(GLSLShader* shader);
302 
306  void discardAllShaders();
307 
309  String infoLog() const;
310 
312  bool validateProgram() const;
313 
316  void bindAttribLocation(unsigned int index, const char* name);
317 
320  int getAttribLocation(const char* name) const
321  {
322  VL_CHECK_OGL();
323  VL_CHECK( Has_GLSL )
324  VL_CHECK( handle() )
325  if( ! Has_GLSL || ! linked() ) {
326  return -1;
327  }
328  int location = glGetAttribLocation( handle(), name );
329  VL_CHECK_OGL();
330  return location;
331  }
332 
334  int shaderCount() const { return (int)mShaders.size(); }
335 
337  const GLSLShader* shader(int i) const { return mShaders[i].get(); }
338 
340  GLSLShader* shader(int i) { return mShaders[i].get(); }
341 
343  void detachAllShaders();
344 
345  // --------------- bind frag data location ---------------
346 
347  void bindFragDataLocation(int color_number, const char* name);
348 
349  void unbindFragDataLocation(const char* name);
350 
351  int fragDataLocation(const char* name) const;
352 
353  const std::map<std::string, int>& fragDataLocations() const { return mFragDataLocation; }
354 
355  // --------------- geometry shader ---------------
356 
357  // --------------- GLSL 4.x ---------------
358 
362  void setProgramBinaryRetrievableHint(bool hint) { mProgramBinaryRetrievableHint = hint; }
363 
367  bool programBinaryRetrievableHint() const { return mProgramBinaryRetrievableHint; }
368 
371  void setProgramSeparable(bool separable)
372  {
373  if (mProgramSeparable != separable)
374  {
375  scheduleRelinking();
376  mProgramSeparable = separable;
377  }
378  }
379 
381  bool programSeparable() const { return mProgramSeparable; }
382 
384  bool getProgramBinary(GLenum& binary_format, std::vector<unsigned char>& binary) const;
385 
387  bool programBinary(GLenum binary_format, const std::vector<unsigned char>& binary) { return programBinary(binary_format, &binary[0], (int)binary.size()); }
388 
390  bool programBinary(GLenum binary_format, const void* binary, int length);
391 
392  // --------------- uniform variables ---------------
393 
400  bool applyUniformSet(const UniformSet* uniforms = NULL) const;
401 
405  int getUniformLocation(const char* name) const
406  {
407  VL_CHECK_OGL();
408  VL_CHECK( Has_GLSL )
409  VL_CHECK( handle() )
410  if( ! Has_GLSL || ! linked() ) {
411  return -1;
412  }
413  int location = glGetUniformLocation( handle(), name );
414  VL_CHECK_OGL();
415  return location;
416  }
417 
418  // --------------- uniform variables: getters ---------------
419 
420  // general uniform getters: use these to access to all the types supported by your GLSL implementation,
421  // and not only the ordinary fvec2, fvec3, fvec4, ivec2, ivec3, ivec4, fmat2, fmat3, fmat4
422 
424  void getUniformfv(int location, float* params) const
425  {
426  VL_CHECK( Has_GLSL )
427  if( !Has_GLSL )
428  return;
429  VL_CHECK(linked())
430  VL_CHECK(handle())
431  glGetUniformfv(handle(), location, params); VL_CHECK_OGL()
432  }
434  void getUniformfv(const char* name, float* params) const { getUniformfv(getUniformLocation(name), params); }
436  void getUniformiv(int location, int* params) const
437  {
438  VL_CHECK( Has_GLSL )
439  if( !Has_GLSL )
440  return;
441  VL_CHECK(linked())
442  VL_CHECK(handle())
443  glGetUniformiv(handle(), location, params); VL_CHECK_OGL()
444  }
446  void getUniformiv(const char* name, int* params) const { getUniformiv(getUniformLocation(name), params); }
447 
448  // utility functions for fvec2, fvec3, fvec4, ivec2, ivec3, ivec4, fmat2, fmat3, fmat4
449 
450  void getUniform(int location, fvec2& vec) const { getUniformfv(location, vec.ptr()); }
451  void getUniform(int location, fvec3& vec) const { getUniformfv(location, vec.ptr()); }
452  void getUniform(int location, fvec4& vec) const { getUniformfv(location, vec.ptr()); }
453  void getUniform(int location, fmat2& mat) const { getUniformfv(location, mat.ptr()); }
454  void getUniform(int location, fmat3& mat) const { getUniformfv(location, mat.ptr()); }
455  void getUniform(int location, fmat4& mat) const { getUniformfv(location, mat.ptr()); }
456  void getUniform(int location, ivec2& vec) const { getUniformiv(location, vec.ptr()); }
457  void getUniform(int location, ivec3& vec) const { getUniformiv(location, vec.ptr()); }
458  void getUniform(int location, ivec4& vec) const { getUniformiv(location, vec.ptr()); }
459  void getUniform(const char* name, fvec2& vec) const { getUniform(getUniformLocation(name), vec); }
460  void getUniform(const char* name, fvec3& vec) const { getUniform(getUniformLocation(name), vec); }
461  void getUniform(const char* name, fvec4& vec) const { getUniform(getUniformLocation(name), vec); }
462  void getUniform(const char* name, fmat2& mat) const { getUniform(getUniformLocation(name), mat); }
463  void getUniform(const char* name, fmat3& mat) const { getUniform(getUniformLocation(name), mat); }
464  void getUniform(const char* name, fmat4& mat) const { getUniform(getUniformLocation(name), mat); }
465  void getUniform(const char* name, ivec2& vec) const { getUniform(getUniformLocation(name), vec); }
466  void getUniform(const char* name, ivec3& vec) const { getUniform(getUniformLocation(name), vec); }
467  void getUniform(const char* name, ivec4& vec) const { getUniform(getUniformLocation(name), vec); }
468 
470  UniformSet* getUniformSet() { return mUniformSet.get(); }
472  const UniformSet* getUniformSet() const { return mUniformSet.get(); }
474  void setUniformSet(UniformSet* uniforms) { mUniformSet = uniforms; }
476  void setUniform(Uniform* uniform) { if (!getUniformSet()) setUniformSet(new UniformSet); getUniformSet()->setUniform(uniform); }
478  Uniform* getUniform(const char* name) { if (!getUniformSet()) return NULL; return getUniformSet()->getUniform(name); }
480  Uniform* gocUniform(const char* name) { if (!getUniformSet()) setUniformSet(new UniformSet); return getUniformSet()->gocUniform(name); }
482  void eraseUniform(const char* name) { if(getUniformSet()) getUniformSet()->eraseUniform(name); }
484  void eraseUniform(const Uniform* uniform) { if(getUniformSet()) getUniformSet()->eraseUniform(uniform); }
486  void eraseAllUniforms() { if(getUniformSet()) getUniformSet()->eraseAllUniforms(); }
487 
490  int vl_WorldMatrix() const { return m_vl_WorldMatrix; }
491 
494  int vl_ModelViewMatrix() const { return m_vl_ModelViewMatrix; }
495 
499  int vl_ProjectionMatrix() const { return m_vl_ProjectionMatrix; }
500 
502  int vl_ModelViewProjectionMatrix() const { return m_vl_ModelViewProjectionMatrix; }
503 
507  int vl_NormalMatrix() const { return m_vl_NormalMatrix; }
508 
509  // --- vertex attribute binding ---
510 
511  int vl_VertexPosition() const { return m_vl_VertexPosition; }
512  int vl_VertexNormal() const { return m_vl_VertexNormal; }
513  int vl_VertexColor() const { return m_vl_VertexColor; }
514  int vl_VertexSecondaryColor() const { return m_vl_VertexSecondaryColor; }
515  int vl_VertexFogCoord() const { return m_vl_VertexFogCoord; }
516  int vl_VertexTexCoord0() const { return m_vl_VertexTexCoord0; }
517  int vl_VertexTexCoord1() const { return m_vl_VertexTexCoord1; }
518  int vl_VertexTexCoord2() const { return m_vl_VertexTexCoord2; }
519  int vl_VertexTexCoord3() const { return m_vl_VertexTexCoord3; }
520  int vl_VertexTexCoord4() const { return m_vl_VertexTexCoord4; }
521  int vl_VertexTexCoord5() const { return m_vl_VertexTexCoord5; }
522  int vl_VertexTexCoord6() const { return m_vl_VertexTexCoord6; }
523  int vl_VertexTexCoord7() const { return m_vl_VertexTexCoord7; }
524  int vl_VertexTexCoord8() const { return m_vl_VertexTexCoord8; }
525  int vl_VertexTexCoord9() const { return m_vl_VertexTexCoord9; }
526  int vl_VertexTexCoord10() const { return m_vl_VertexTexCoord10; }
527 
528  private:
529  void preLink();
530  void postLink();
531  void operator=(const GLSLProgram&) { }
532  void resetBindingLocations();
533 
534  protected:
535  std::vector< ref<GLSLShader> > mShaders;
536  std::map<std::string, int> mFragDataLocation;
538  unsigned int mHandle;
540 
541  // glProgramParameter
544 
545  // VL standard uniforms
546 
552 
553  // VL standard vertex attributes
554 
571  };
572 }
573 
574 #endif
int vl_VertexSecondaryColor() const
Definition: GLSL.hpp:514
int vl_VertexTexCoord0() const
Definition: GLSL.hpp:516
GLSLShader * shader(int i)
Returns the i-th GLSLShader objects bound to this GLSLProgram.
Definition: GLSL.hpp:340
void eraseUniform(const Uniform *uniform)
Utility function using getUniformSet(). Erases the specified uniform.
Definition: GLSL.hpp:484
Wraps an OpenGL Shading Language uniform to be associated to a GLSLProgram (see vl::GLSLProgram docum...
Definition: Uniform.hpp:59
GLSLTessControlShader(const String &source=String())
Definition: GLSL.hpp:178
A shader that is intended to run on the programmable geometry processor.
A shader that is intended to run on the programmable vertex processor.
int m_vl_VertexTexCoord6
Definition: GLSL.hpp:566
A shader that is intended to run on the programmable fragment processor.
void getUniform(int location, fmat4 &mat) const
Definition: GLSL.hpp:455
ERenderState
int getUniformLocation(const char *name) const
Returns the binding index of the given uniform.
Definition: GLSL.hpp:405
bool mProgramBinaryRetrievableHint
Definition: GLSL.hpp:542
void getUniform(int location, ivec3 &vec) const
Definition: GLSL.hpp:457
The Renderer class executes the actual rendering on the given RenderQueue.
Definition: Renderer.hpp:49
int m_vl_VertexTexCoord3
Definition: GLSL.hpp:563
void setType(EShaderType type)
Definition: GLSL.hpp:64
GLSLVertexShader(const String &source=String())
Constructor.
Definition: GLSL.hpp:124
void getUniform(int location, fvec4 &vec) const
Definition: GLSL.hpp:452
int vl_VertexColor() const
Definition: GLSL.hpp:513
EShaderType mType
Definition: GLSL.hpp:107
unsigned int handle() const
The handle of this OpenGL shader object as returned by glCreateShader()
Definition: GLSL.hpp:104
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
Wraps a GLSL geometry shader to be bound to a GLSLProgram: the shader this shader will run on the pro...
Definition: GLSL.hpp:154
void getUniform(const char *name, fmat4 &mat) const
Definition: GLSL.hpp:464
T_Scalar * ptr()
Definition: Matrix2.hpp:243
Wraps a GLSL vertex shader to be bound to a GLSLProgram: the shader this shader will run on the progr...
Definition: GLSL.hpp:117
int m_vl_VertexPosition
Definition: GLSL.hpp:555
virtual ref< RenderState > clone() const
Definition: GLSL.hpp:249
bool linked() const
Returns true if the program has been succesfully linked.
Definition: GLSL.hpp:288
Uniform * gocUniform(const char *name)
Utility function using getUniformSet(). Gets or creates the specified Uniform.
Definition: GLSL.hpp:480
void getUniform(int location, ivec2 &vec) const
Definition: GLSL.hpp:456
bool mScheduleLink
Definition: GLSL.hpp:539
GLSLGeometryShader(const String &source=String())
Definition: GLSL.hpp:160
int vl_VertexTexCoord9() const
Definition: GLSL.hpp:525
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
The Matrix2 class is a template class that implements a generic 2x2 matrix, see also vl::dmat2...
Definition: Matrix2.hpp:49
unsigned int mHandle
Definition: GLSL.hpp:110
std::vector< ref< GLSLShader > > mShaders
Definition: GLSL.hpp:535
void getUniform(const char *name, fmat3 &mat) const
Definition: GLSL.hpp:463
void setProgramSeparable(bool separable)
Indicates whether program can be bound to individual pipeline stages via glUseProgramStages, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramParameter.xml.
Definition: GLSL.hpp:371
int m_vl_VertexSecondaryColor
Definition: GLSL.hpp:558
int m_vl_NormalMatrix
Definition: GLSL.hpp:551
int m_vl_VertexTexCoord1
Definition: GLSL.hpp:561
int vl_ProjectionMatrix() const
Returns the binding location of the vl_ProjectionMatrix uniform variable or -1 if no such variable is...
Definition: GLSL.hpp:499
void setUniformSet(UniformSet *uniforms)
Sets a GLSLProgram&#39;s static UniformSet.
Definition: GLSL.hpp:474
Wraps a GLSL tessellation evaluation shader to be bound to a GLSLProgram: this shader will run on the...
Definition: GLSL.hpp:190
Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders. ...
Definition: GLSL.hpp:233
void getUniformfv(const char *name, float *params) const
Equivalent to getUniformfv(getUniformLocation(name), params)
Definition: GLSL.hpp:434
int m_vl_VertexColor
Definition: GLSL.hpp:557
unsigned int mHandle
Definition: GLSL.hpp:538
int vl_VertexNormal() const
Definition: GLSL.hpp:512
int m_vl_VertexNormal
Definition: GLSL.hpp:556
const std::string & source() const
Returns the sources for this shader.
Definition: GLSL.hpp:72
void getUniformiv(int location, int *params) const
Equivalent to glGetUniformiv(handle(), location, params)
Definition: GLSL.hpp:436
String mPath
Definition: GLSL.hpp:109
bool mProgramSeparable
Definition: GLSL.hpp:543
void getUniform(const char *name, ivec4 &vec) const
Definition: GLSL.hpp:467
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
void setProgramBinaryRetrievableHint(bool hint)
Indicate to the implementation the intention of the application to retrieve the program&#39;s binary repr...
Definition: GLSL.hpp:362
void getUniform(const char *name, fvec2 &vec) const
Definition: GLSL.hpp:459
void getUniform(int location, ivec4 &vec) const
Definition: GLSL.hpp:458
int m_vl_VertexTexCoord8
Definition: GLSL.hpp:568
int vl_VertexTexCoord7() const
Definition: GLSL.hpp:523
Visualization Library main namespace.
Wraps a GLSL tessellation control shader to be bound to a GLSLProgram: the shader this shader will ru...
Definition: GLSL.hpp:172
bool Has_GLSL
Definition: OpenGL.cpp:73
Wraps a GLSL fragment shader to be bound to a GLSLProgram: the shader this shader will run on the pro...
Definition: GLSL.hpp:136
int vl_VertexTexCoord3() const
Definition: GLSL.hpp:519
void scheduleRelinking()
Schedules a relink of the GLSL program.
Definition: GLSL.hpp:291
int vl_WorldMatrix() const
Returns the binding location of the vl_WorldMatrix uniform variable or -1 if no such variable is used...
Definition: GLSL.hpp:490
T_Scalar * ptr()
Definition: Vector2.hpp:130
int m_vl_VertexFogCoord
Definition: GLSL.hpp:559
int vl_ModelViewMatrix() const
Returns the binding location of the vl_ModelViewMatrix uniform variable or -1 if no such variable is ...
Definition: GLSL.hpp:494
The Matrix3 class is a template class that implements a generic 3x3 matrix, see also vl::dmat3...
Definition: Matrix3.hpp:48
void setPath(const String &path)
The path from which the shader was loaded.
Definition: GLSL.hpp:75
int vl_VertexTexCoord2() const
Definition: GLSL.hpp:518
A shader that is intended to run on the programmable tessellation processor in the evaluation stage...
void getUniform(const char *name, fvec3 &vec) const
Definition: GLSL.hpp:460
void eraseUniform(const char *name)
Utility function using getUniformSet(). Erases the specified uniform.
Definition: GLSL.hpp:482
void getUniform(int location, fvec2 &vec) const
Definition: GLSL.hpp:450
GLSLTessEvaluationShader(const String &source=String())
Definition: GLSL.hpp:196
const std::map< std::string, int > & fragDataLocations() const
Definition: GLSL.hpp:353
For internal use only.
Definition: GLSL.hpp:50
int vl_VertexTexCoord10() const
Definition: GLSL.hpp:526
void getUniform(int location, fvec3 &vec) const
Definition: GLSL.hpp:451
T_Scalar * ptr()
Definition: Matrix3.hpp:306
UniformSet * getUniformSet()
Returns a GLSLProgram&#39;s static UniformSet. Static uniforms are those uniforms whose value is constant...
Definition: GLSL.hpp:470
GLSLFragmentShader(const String &source=String())
Definition: GLSL.hpp:142
The base class for all the reference counted objects.
Definition: Object.hpp:158
int m_vl_VertexTexCoord9
Definition: GLSL.hpp:569
Base class for those render states which have only one binding point (the vast majority).
Definition: RenderState.hpp:84
int vl_VertexTexCoord4() const
Definition: GLSL.hpp:520
Implements the OpenGL Shading Language convenience functions for scalar and vector operations...
int m_vl_ModelViewMatrix
Definition: GLSL.hpp:548
bool programBinaryRetrievableHint() const
Indicate to the implementation the intention of the application to retrieve the program&#39;s binary repr...
Definition: GLSL.hpp:367
bool programSeparable() const
Indicates whether program can be bound to individual pipeline stages via glUseProgramStages, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramParameter.xml.
Definition: GLSL.hpp:381
void setUniform(Uniform *uniform)
Utility function using getUniformSet(). Adds a Uniform to this program&#39;s static uniform set...
Definition: GLSL.hpp:476
bool mCompiled
Definition: GLSL.hpp:111
void getUniform(const char *name, fmat2 &mat) const
Definition: GLSL.hpp:462
int m_vl_VertexTexCoord5
Definition: GLSL.hpp:565
int m_vl_WorldMatrix
Definition: GLSL.hpp:547
int getAttribLocation(const char *name) const
Eqivalento to glGetAttribLocation(handle(), name).
Definition: GLSL.hpp:320
bool programBinary(GLenum binary_format, const std::vector< unsigned char > &binary)
glProgramBinary wrapper: loads a program object with a program binary, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramBinary.xml
Definition: GLSL.hpp:387
int vl_NormalMatrix() const
Returns the binding location of the vl_NormalMatrix uniform variable or -1 if no such variable is use...
Definition: GLSL.hpp:507
int m_vl_VertexTexCoord7
Definition: GLSL.hpp:567
int vl_VertexTexCoord1() const
Definition: GLSL.hpp:517
int m_vl_ProjectionMatrix
Definition: GLSL.hpp:549
#define NULL
Definition: OpenGLDefs.hpp:81
A shader that is intended to run on the programmable tessellation processor in the control stage...
int m_vl_VertexTexCoord10
Definition: GLSL.hpp:570
void getUniformiv(const char *name, int *params) const
Equivalent to getUniformiv(getUniformLocation(name)
Definition: GLSL.hpp:446
T_Scalar * ptr()
Definition: Vector3.hpp:87
int m_vl_ModelViewProjectionMatrix
Definition: GLSL.hpp:550
std::map< std::string, int > mFragDataLocation
Definition: GLSL.hpp:536
#define VL_CHECK_OGL()
Definition: OpenGL.hpp:156
int m_vl_VertexTexCoord4
Definition: GLSL.hpp:564
EShaderType type() const
Definition: GLSL.hpp:66
T_Scalar * ptr()
Definition: Vector4.hpp:99
int m_vl_VertexTexCoord0
Definition: GLSL.hpp:560
T_Scalar * ptr()
Definition: Matrix4.hpp:345
void getUniform(const char *name, ivec2 &vec) const
Definition: GLSL.hpp:465
std::string mSource
Definition: GLSL.hpp:108
const String & path() const
The path from which the shader was loaded.
Definition: GLSL.hpp:78
const UniformSet * getUniformSet() const
Returns a GLSLProgram&#39;s static UniformSet. Static uniforms are those uniforms whose value is constant...
Definition: GLSL.hpp:472
A set of Uniform objects managed by a Shader.
Definition: UniformSet.hpp:50
int vl_VertexTexCoord6() const
Definition: GLSL.hpp:522
int m_vl_VertexTexCoord2
Definition: GLSL.hpp:562
void getUniform(const char *name, fvec4 &vec) const
Definition: GLSL.hpp:461
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
ref< UniformSet > mUniformSet
Definition: GLSL.hpp:537
T length(T v)
Definition: glsl_math.hpp:1084
void getUniform(const char *name, ivec3 &vec) const
Definition: GLSL.hpp:466
void getUniform(int location, fmat2 &mat) const
Definition: GLSL.hpp:453
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:49
unsigned int handle() const
The handle of the GLSL program as returned by glCreateProgram()
Definition: GLSL.hpp:273
Uniform * getUniform(const char *name)
Utility function using getUniformSet(). Returns the specified Uniform. Returns NULL if there isn&#39;t su...
Definition: GLSL.hpp:478
void getUniform(int location, fmat3 &mat) const
Definition: GLSL.hpp:454
int shaderCount() const
Returns the number of GLSLShader objects bound to this GLSLProgram.
Definition: GLSL.hpp:334
void getUniformfv(int location, float *params) const
Equivalent to glGetUniformfv(handle(), location, params)
Definition: GLSL.hpp:424
#define VL_CHECK(expr)
Definition: checks.hpp:73
void eraseAllUniforms()
Utility function using getUniformSet(). Erases all the uniforms.
Definition: GLSL.hpp:486
const GLSLShader * shader(int i) const
Returns the i-th GLSLShader objects bound to this GLSLProgram.
Definition: GLSL.hpp:337
int vl_VertexTexCoord5() const
Definition: GLSL.hpp:521
int vl_ModelViewProjectionMatrix() const
Returns the binding location of the vl_ModelViewProjectionMatrix uniform variable or -1 if no such va...
Definition: GLSL.hpp:502
int vl_VertexFogCoord() const
Definition: GLSL.hpp:515
int vl_VertexPosition() const
Definition: GLSL.hpp:511
int vl_VertexTexCoord8() const
Definition: GLSL.hpp:524