OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
State.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_STATE
15 #define OSG_STATE 1
16 
17 #include <osg/Export>
18 #include <osg/GLExtensions>
19 #include <osg/StateSet>
20 #include <osg/Matrix>
21 #include <osg/Uniform>
22 #include <osg/BufferObject>
23 #include <osg/Observer>
24 #include <osg/Timer>
25 
26 #include <osg/ShaderComposer>
27 #include <osg/FrameStamp>
28 #include <osg/DisplaySettings>
29 #include <osg/Polytope>
30 #include <osg/Viewport>
31 #include <osg/GLBeginEndAdapter>
32 #include <osg/ArrayDispatchers>
33 #include <osg/GraphicsCostEstimator>
34 
35 #include <iosfwd>
36 #include <vector>
37 #include <map>
38 #include <set>
39 #include <string>
40 
41 #ifndef GL_FOG_COORDINATE_ARRAY
42  #ifdef GL_FOG_COORDINATE_ARRAY_EXT
43  #define GL_FOG_COORDINATE_ARRAY GL_FOG_COORDINATE_ARRAY_EXT
44  #else
45  #define GL_FOG_COORDINATE_ARRAY 0x8457
46  #endif
47 #endif
48 
49 #ifndef GL_SECONDARY_COLOR_ARRAY
50  #ifdef GL_SECONDARY_COLOR_ARRAY_EXT
51  #define GL_SECONDARY_COLOR_ARRAY GL_SECONDARY_COLOR_ARRAY_EXT
52  #else
53  #define GL_SECONDARY_COLOR_ARRAY 0x845E
54  #endif
55 #endif
56 
57 namespace osg {
58 
61 #define OSG_GL_DEBUG(message) \
62  if (state.getFineGrainedErrorDetection()) \
63  { \
64  GLenum errorNo = glGetError(); \
65  if (errorNo!=GL_NO_ERROR) \
66  { \
67  osg::notify(WARN)<<"Warning: detected OpenGL error '"<<gluErrorString(errorNo)<<" "<<message<<endl; \
68  }\
69  }
70 
71 
72 // forward declare GraphicsContext, View and State
73 class GraphicsContext;
74 
76 {
77  public:
79  _location(0) {}
80 
82  _location(rhs._location),
83  _glName(rhs._glName),
84  _osgName(rhs._osgName),
86 
87  VertexAttribAlias(GLuint location, const std::string glName, const std::string osgName, const std::string& declaration):
88  _location(location),
89  _glName(glName),
90  _osgName(osgName),
91  _declaration(declaration) {}
92 
93  GLuint _location;
94  std::string _glName;
95  std::string _osgName;
96  std::string _declaration;
97 };
98 
99 
117 {
118  public :
119 
120  State();
121 
122 
124  void setGraphicsContext(GraphicsContext* context) { _graphicsContext = context; }
125 
127  GraphicsContext* getGraphicsContext() { return _graphicsContext; }
128 
130  const GraphicsContext* getGraphicsContext() const { return _graphicsContext; }
131 
132 
148  inline void setContextID(unsigned int contextID) { _contextID=contextID; }
149 
151  inline unsigned int getContextID() const { return _contextID; }
152 
153 
154  // ExtensionMap contains GL Extentsions objects used by StateAttribue to call OpenGL extensions/advanced features
155  typedef std::map<const std::type_info*, osg::ref_ptr<osg::Referenced> > ExtensionMap;
156  ExtensionMap _extensionMap;
157 
160  template<typename T>
161  T* get()
162  {
163  const std::type_info* id(&typeid(T));
164  osg::ref_ptr<osg::Referenced>& ptr = _extensionMap[id];
165  if (!ptr)
166  {
167  ptr = new T(_contextID);
168  }
169  return static_cast<T*>(ptr.get());
170  }
171 
175  template<typename T>
176  const T* get() const
177  {
178  const std::type_info* id(&typeid(T));
179  ExtensionMap::const_iterator itr = _extensionMap.find(id);
180  if (itr==_extensionMap.end()) return 0;
181  else return itr->second.get();
182  }
183 
184 
185  /* Set whether shader composition is enabled.*/
186  void setShaderCompositionEnabled(bool flag) { _shaderCompositionEnabled = flag; }
187 
188  /* Get whether shader composition is enabled.*/
189  bool getShaderCompositionEnabled() const { return _shaderCompositionEnabled; }
190 
192  void setShaderComposer(ShaderComposer* sc) { _shaderComposer = sc; }
193 
195  ShaderComposer* getShaderComposer() { return _shaderComposer.get(); }
196 
198  const ShaderComposer* getShaderComposer() const { return _shaderComposer.get(); }
199 
201  StateSet::UniformList& getCurrentShaderCompositionUniformList() { return _currentShaderCompositionUniformList; }
202 
205  {
206  StateSet::RefUniformPair& up = _currentShaderCompositionUniformList[uniform->getName()];
207  up.first = const_cast<Uniform*>(uniform);
208  up.second = value;
209  }
210 
211 
213  void pushStateSet(const StateSet* dstate);
214 
216  void popStateSet();
217 
220  void popAllStateSets();
221 
223  void insertStateSet(unsigned int pos,const StateSet* dstate);
224 
226  void removeStateSet(unsigned int pos);
227 
229  unsigned int getStateSetStackSize() { return static_cast<unsigned int>(_stateStateStack.size()); }
230 
232  void popStateSetStackToSize(unsigned int size) { while (_stateStateStack.size()>size) popStateSet(); }
233 
234  typedef std::vector<const StateSet*> StateSetStack;
235 
237  StateSetStack& getStateSetStack() { return _stateStateStack; }
238 
239 
241  void captureCurrentState(StateSet& stateset) const;
242 
244  void releaseGLObjects();
245 
247  void reset();
248 
249  inline const Viewport* getCurrentViewport() const
250  {
251  return static_cast<const Viewport*>(getLastAppliedAttribute(osg::StateAttribute::VIEWPORT));
252  }
253 
254 
255  void setInitialViewMatrix(const osg::RefMatrix* matrix);
256 
257  inline const osg::Matrix& getInitialViewMatrix() const { return *_initialViewMatrix; }
258  inline const osg::Matrix& getInitialInverseViewMatrix() const { return _initialInverseViewMatrix; }
259 
260  void applyProjectionMatrix(const osg::RefMatrix* matrix);
261 
262  inline const osg::Matrix& getProjectionMatrix() const { return *_projection; }
263 
264  void applyModelViewMatrix(const osg::RefMatrix* matrix);
265  void applyModelViewMatrix(const osg::Matrix&);
266 
267  const osg::Matrix& getModelViewMatrix() const { return *_modelView; }
268 
269  void setUseModelViewAndProjectionUniforms(bool flag) { _useModelViewAndProjectionUniforms = flag; }
270  bool getUseModelViewAndProjectionUniforms() const { return _useModelViewAndProjectionUniforms; }
271 
272  void updateModelViewAndProjectionMatrixUniforms();
273 
274  void applyModelViewAndProjectionUniformsIfRequired();
275 
276  osg::Uniform* getModelViewMatrixUniform() { return _modelViewMatrixUniform.get(); }
277  osg::Uniform* getProjectionMatrixUniform() { return _projectionMatrixUniform.get(); }
278  osg::Uniform* getModelViewProjectionMatrixUniform() { return _modelViewProjectionMatrixUniform.get(); }
279  osg::Uniform* getNormalMatrixUniform() { return _normalMatrixUniform.get(); }
280 
281 
282  Polytope getViewFrustum() const;
283 
284 
285  void setUseVertexAttributeAliasing(bool flag) { _useVertexAttributeAliasing = flag; }
286  bool getUseVertexAttributeAliasing() const { return _useVertexAttributeAliasing ; }
287 
288  typedef std::vector<VertexAttribAlias> VertexAttribAliasList;
289 
291  void resetVertexAttributeAlias(bool compactAliasing=true, unsigned int numTextureUnits=8);
292 
294  void setVertexAlias(const VertexAttribAlias& alias) { _vertexAlias = alias; }
295  const VertexAttribAlias& getVertexAlias() { return _vertexAlias; }
296 
298  void setNormalAlias(const VertexAttribAlias& alias) { _normalAlias = alias; }
299  const VertexAttribAlias& getNormalAlias() { return _normalAlias; }
300 
302  void setColorAlias(const VertexAttribAlias& alias) { _colorAlias = alias; }
303  const VertexAttribAlias& getColorAlias() { return _colorAlias; }
304 
306  void setSecondaryColorAlias(const VertexAttribAlias& alias) { _secondaryColorAlias = alias; }
307  const VertexAttribAlias& getSecondaryColorAlias() { return _secondaryColorAlias; }
308 
310  void setFogCoordAlias(const VertexAttribAlias& alias) { _fogCoordAlias = alias; }
311  const VertexAttribAlias& getFogCoordAlias() { return _fogCoordAlias; }
312 
314  void setTexCoordAliasList(const VertexAttribAliasList& aliasList) { _texCoordAliasList = aliasList; }
315  const VertexAttribAliasList& getTexCoordAliasList() { return _texCoordAliasList; }
316 
318  void setAttributeBindingList(const Program::AttribBindingList& attribBindingList) { _attributeBindingList = attribBindingList; }
319  const Program::AttribBindingList& getAttributeBindingList() { return _attributeBindingList; }
320 
321  bool convertVertexShaderSourceToOsgBuiltIns(std::string& source) const;
322 
323 
325  void apply(const StateSet* dstate);
326 
331  void apply();
332 
334  void applyShaderComposition();
335 
338  inline void setModeValidity(StateAttribute::GLMode mode,bool valid)
339  {
340  ModeStack& ms = _modeMap[mode];
341  ms.valid = valid;
342  }
343 
347  {
348  ModeStack& ms = _modeMap[mode];
349  return ms.valid;
350  }
351 
352  inline void setGlobalDefaultModeValue(StateAttribute::GLMode mode,bool enabled)
353  {
354  ModeStack& ms = _modeMap[mode];
355  ms.global_default_value = enabled;
356  }
357 
359  {
360  return _modeMap[mode].global_default_value;
361  }
362 
363 
373  inline bool applyMode(StateAttribute::GLMode mode,bool enabled)
374  {
375  ModeStack& ms = _modeMap[mode];
376  ms.changed = true;
377  return applyMode(mode,enabled,ms);
378  }
379 
380  inline void setGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode,bool enabled)
381  {
382  ModeMap& modeMap = getOrCreateTextureModeMap(unit);
383  ModeStack& ms = modeMap[mode];
384  ms.global_default_value = enabled;
385  }
386 
387  inline bool getGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode)
388  {
389  ModeMap& modeMap = getOrCreateTextureModeMap(unit);
390  ModeStack& ms = modeMap[mode];
391  return ms.global_default_value;
392  }
393 
394  inline bool applyTextureMode(unsigned int unit, StateAttribute::GLMode mode,bool enabled)
395  {
396  ModeMap& modeMap = getOrCreateTextureModeMap(unit);
397  ModeStack& ms = modeMap[mode];
398  ms.changed = true;
399  return applyModeOnTexUnit(unit,mode,enabled,ms);
400  }
401 
402  inline void setGlobalDefaultAttribute(const StateAttribute* attribute)
403  {
404  AttributeStack& as = _attributeMap[attribute->getTypeMemberPair()];
405  as.global_default_attribute = attribute;
406  }
407 
409  {
410  AttributeStack& as = _attributeMap[StateAttribute::TypeMemberPair(type,member)];
411  return as.global_default_attribute.get();
412  }
413 
415  inline bool applyAttribute(const StateAttribute* attribute)
416  {
417  AttributeStack& as = _attributeMap[attribute->getTypeMemberPair()];
418  as.changed = true;
419  return applyAttribute(attribute,as);
420  }
421 
422  inline void setGlobalDefaultTextureAttribute(unsigned int unit, const StateAttribute* attribute)
423  {
424  AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
425  AttributeStack& as = attributeMap[attribute->getTypeMemberPair()];
426  as.global_default_attribute = attribute;
427  }
428 
429  inline const StateAttribute* getGlobalDefaultTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member = 0)
430  {
431  AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
432  AttributeStack& as = attributeMap[StateAttribute::TypeMemberPair(type,member)];
433  return as.global_default_attribute.get();
434  }
435 
436 
437  inline bool applyTextureAttribute(unsigned int unit, const StateAttribute* attribute)
438  {
439  AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
440  AttributeStack& as = attributeMap[attribute->getTypeMemberPair()];
441  as.changed = true;
442  return applyAttributeOnTexUnit(unit,attribute,as);
443  }
444 
446  void haveAppliedMode(StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
447 
450  void haveAppliedMode(StateAttribute::GLMode mode);
451 
453  void haveAppliedAttribute(const StateAttribute* attribute);
454 
462  void haveAppliedAttribute(StateAttribute::Type type, unsigned int member=0);
463 
465  bool getLastAppliedMode(StateAttribute::GLMode mode) const;
466 
468  const StateAttribute* getLastAppliedAttribute(StateAttribute::Type type, unsigned int member=0) const;
469 
471  void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
472 
475  void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode);
476 
478  void haveAppliedTextureAttribute(unsigned int unit, const StateAttribute* attribute);
479 
487  void haveAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0);
488 
490  bool getLastAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode) const;
491 
493  const StateAttribute* getLastAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0) const;
494 
495 
497  void dirtyAllModes();
498 
500  void dirtyAllAttributes();
501 
503  void disableAllVertexArrays();
504 
506  void dirtyAllVertexArrays();
507 
508 
509  void setCurrentVertexBufferObject(osg::GLBufferObject* vbo) { _currentVBO = vbo; }
510  const GLBufferObject* getCurrentVertexBufferObject() { return _currentVBO; }
512  {
513  if (vbo == _currentVBO) return;
514  if (vbo->isDirty()) vbo->compileBuffer();
515  else vbo->bindBuffer();
516  _currentVBO = vbo;
517  }
518 
520  {
521  if (!_currentVBO) return;
522  _glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
523  _currentVBO = 0;
524  }
525 
526  void setCurrentElementBufferObject(osg::GLBufferObject* ebo) { _currentEBO = ebo; }
527  const GLBufferObject* getCurrentElementBufferObject() { return _currentEBO; }
528 
530  {
531  if (ebo == _currentEBO) return;
532  if (ebo->isDirty()) ebo->compileBuffer();
533  else ebo->bindBuffer();
534  _currentEBO = ebo;
535  }
536 
538  {
539  if (!_currentEBO) return;
540  _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0);
541  _currentEBO = 0;
542  }
543 
544  void setCurrentPixelBufferObject(osg::GLBufferObject* pbo) { _currentPBO = pbo; }
545  const GLBufferObject* getCurrentPixelBufferObject() { return _currentPBO; }
546 
548  {
549  if (pbo == _currentPBO) return;
550 
551  if (pbo->isDirty()) pbo->compileBuffer();
552  else pbo->bindBuffer();
553 
554  _currentPBO = pbo;
555  }
556 
558  {
559  if (!_currentPBO) return;
560 
561  _glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,0);
562  _currentPBO = 0;
563  }
564 
565  typedef std::vector<GLushort> IndicesGLushort;
566  IndicesGLushort _quadIndicesGLushort[4];
567 
568  typedef std::vector<GLuint> IndicesGLuint;
569  IndicesGLuint _quadIndicesGLuint[4];
570 
571  void drawQuads(GLint first, GLsizei count, GLsizei primCount=0);
572 
573  inline void glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
574  {
575  if (primcount>=1 && _glDrawArraysInstanced!=0) _glDrawArraysInstanced(mode, first, count, primcount);
576  else glDrawArrays(mode, first, count);
577  }
578 
579  inline void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount )
580  {
581  if (primcount>=1 && _glDrawElementsInstanced!=0) _glDrawElementsInstanced(mode, count, type, indices, primcount);
582  else glDrawElements(mode, count, type, indices);
583  }
584 
585 
586  inline void Vertex(float x, float y, float z, float w=1.0f)
587  {
588  #if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
589  if (_useVertexAttributeAliasing) _glVertexAttrib4f( _vertexAlias._location, x,y,z,w);
590  else glVertex4f(x,y,z,w);
591  #else
592  _glVertexAttrib4f( _vertexAlias._location, x,y,z,w);
593  #endif
594  }
595 
596  inline void Color(float r, float g, float b, float a=1.0f)
597  {
598  #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
599  if (_useVertexAttributeAliasing) _glVertexAttrib4f( _colorAlias._location, r,g,b,a);
600  else glColor4f(r,g,b,a);
601  #else
602  _glVertexAttrib4f( _colorAlias._location, r,g,b,a);
603  #endif
604  }
605 
606  void Normal(float x, float y, float z)
607  {
608  #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
609  if (_useVertexAttributeAliasing) _glVertexAttrib4f( _normalAlias._location, x,y,z,0.0);
610  else glNormal3f(x,y,z);
611  #else
612  _glVertexAttrib4f( _normalAlias._location, x,y,z,0.0);
613  #endif
614  }
615 
616  void TexCoord(float x, float y=0.0f, float z=0.0f, float w=1.0f)
617  {
618  #if !defined(OSG_GLES1_AVAILABLE)
619  #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
620  if (_useVertexAttributeAliasing) _glVertexAttrib4f( _texCoordAliasList[0]._location, x,y,z,w);
621  else glTexCoord4f(x,y,z,w);
622  #else
623  _glVertexAttrib4f( _texCoordAliasList[0]._location, x,y,z,w);
624  #endif
625  #endif
626  }
627 
628  void MultiTexCoord(unsigned int unit, float x, float y=0.0f, float z=0.0f, float w=1.0f)
629  {
630  #if !defined(OSG_GLES1_AVAILABLE)
631  #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
632  if (_useVertexAttributeAliasing) _glVertexAttrib4f( _texCoordAliasList[unit]._location, x,y,z,w);
633  else _glMultiTexCoord4f(GL_TEXTURE0+unit,x,y,z,w);
634  #else
635  _glVertexAttrib4f( _texCoordAliasList[unit]._location, x,y,z,w);
636  #endif
637  #endif
638  }
639 
640  void VerteAttrib(unsigned int location, float x, float y=0.0f, float z=0.0f, float w=0.0f)
641  {
642  _glVertexAttrib4f( location, x,y,z,w);
643  }
644 
645 
647  void lazyDisablingOfVertexAttributes();
648 
650  void applyDisablingOfVertexAttributes();
651 
655  void setInterleavedArrays( GLenum format, GLsizei stride, const GLvoid* pointer);
656 
658  inline void setVertexPointer(const Array* array)
659  {
660  if (array)
661  {
662  GLBufferObject* vbo = isVertexBufferObjectSupported() ? array->getOrCreateGLBufferObject(_contextID) : 0;
663  if (vbo)
664  {
665  bindVertexBufferObject(vbo);
666  setVertexPointer(array->getDataSize(),array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex())),array->getNormalize());
667  }
668  else
669  {
670  unbindVertexBufferObject();
671  setVertexPointer(array->getDataSize(),array->getDataType(),0,array->getDataPointer(),array->getNormalize());
672  }
673  }
674  }
675 
678  inline void setVertexPointer( GLint size, GLenum type,
679  GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE )
680  {
681  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
682  if (_useVertexAttributeAliasing)
683  {
684  setVertexAttribPointer(_vertexAlias._location, size, type, normalized, stride, ptr);
685  }
686  else
687  {
688  if (!_vertexArray._enabled || _vertexArray._dirty)
689  {
690  _vertexArray._enabled = true;
691  glEnableClientState(GL_VERTEX_ARRAY);
692  }
693  //if (_vertexArray._pointer!=ptr || _vertexArray._dirty)
694  {
695  _vertexArray._pointer=ptr;
696  glVertexPointer( size, type, stride, ptr );
697  }
698  _vertexArray._lazy_disable = false;
699  _vertexArray._dirty = false;
700  _vertexArray._normalized = normalized;
701  }
702  #else
703  setVertexAttribPointer(_vertexAlias._location, size, type, normalized, stride, ptr);
704  #endif
705  }
706 
709  inline void disableVertexPointer()
710  {
711  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
712  if (_useVertexAttributeAliasing)
713  {
714  disableVertexAttribPointer(_vertexAlias._location);
715  }
716  else
717  {
718  if (_vertexArray._enabled || _vertexArray._dirty)
719  {
720  _vertexArray._lazy_disable = false;
721  _vertexArray._enabled = false;
722  _vertexArray._dirty = false;
723  glDisableClientState(GL_VERTEX_ARRAY);
724  }
725  }
726  #else
727  disableVertexAttribPointer(_vertexAlias._location);
728  #endif
729  }
730 
731  inline void dirtyVertexPointer()
732  {
733  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
734  if (_useVertexAttributeAliasing)
735  {
736  dirtyVertexAttribPointer(_vertexAlias._location);
737  }
738  else
739  {
740  _vertexArray._pointer = 0;
741  _vertexArray._dirty = true;
742  }
743  #else
744  dirtyVertexAttribPointer(_vertexAlias._location);
745  #endif
746  }
747 
748 
750  inline void setNormalPointer(const Array* array)
751  {
752  if (array)
753  {
754  GLBufferObject* vbo = isVertexBufferObjectSupported() ? array->getOrCreateGLBufferObject(_contextID) : 0;
755  if (vbo)
756  {
757  bindVertexBufferObject(vbo);
758  setNormalPointer(array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex())),array->getNormalize());
759  }
760  else
761  {
762  unbindVertexBufferObject();
763  setNormalPointer(array->getDataType(),0,array->getDataPointer(),array->getNormalize());
764  }
765  }
766  }
767 
770  inline void setNormalPointer( GLenum type, GLsizei stride,
771  const GLvoid *ptr, GLboolean normalized=GL_FALSE )
772  {
773  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
774  if (_useVertexAttributeAliasing)
775  {
776  setVertexAttribPointer(_normalAlias._location, 3, type, normalized, stride, ptr);
777  }
778  else
779  {
780  if (!_normalArray._enabled || _normalArray._dirty)
781  {
782  _normalArray._enabled = true;
783  glEnableClientState(GL_NORMAL_ARRAY);
784  }
785  //if (_normalArray._pointer!=ptr || _normalArray._dirty)
786  {
787  _normalArray._pointer=ptr;
788  glNormalPointer( type, stride, ptr );
789  }
790  _normalArray._lazy_disable = false;
791  _normalArray._dirty = false;
792  _normalArray._normalized = normalized;
793  }
794  #else
795  setVertexAttribPointer(_normalAlias._location, 3, type, normalized, stride, ptr);
796  #endif
797  }
798 
801  inline void disableNormalPointer()
802  {
803  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
804  if (_useVertexAttributeAliasing)
805  {
806  disableVertexAttribPointer(_normalAlias._location);
807  }
808  else
809  {
810  if (_normalArray._enabled || _normalArray._dirty)
811  {
812  _normalArray._lazy_disable = false;
813  _normalArray._enabled = false;
814  _normalArray._dirty = false;
815  glDisableClientState(GL_NORMAL_ARRAY);
816  }
817  }
818  #else
819  disableVertexAttribPointer(_normalAlias._location);
820  #endif
821  }
822 
823  inline void dirtyNormalPointer()
824  {
825  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
826  if (_useVertexAttributeAliasing)
827  {
828  dirtyVertexAttribPointer(_normalAlias._location);
829  }
830  else
831  {
832  _normalArray._pointer = 0;
833  _normalArray._dirty = true;
834  }
835  #else
836  dirtyVertexAttribPointer(_normalAlias._location);
837  #endif
838  }
839 
841  inline void setColorPointer(const Array* array)
842  {
843  if (array)
844  {
845  GLBufferObject* vbo = isVertexBufferObjectSupported() ? array->getOrCreateGLBufferObject(_contextID) : 0;
846  if (vbo)
847  {
848  bindVertexBufferObject(vbo);
849  setColorPointer(array->getDataSize(),array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex())),array->getNormalize());
850  }
851  else
852  {
853  unbindVertexBufferObject();
854  setColorPointer(array->getDataSize(),array->getDataType(),0,array->getDataPointer(),array->getNormalize());
855  }
856  }
857  }
858 
859 
862  inline void setColorPointer( GLint size, GLenum type,
863  GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_TRUE )
864  {
865  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
866  if (_useVertexAttributeAliasing)
867  {
868  setVertexAttribPointer(_colorAlias._location, size, type, normalized, stride, ptr);
869  }
870  else
871  {
872  if (!_colorArray._enabled || _colorArray._dirty)
873  {
874  _colorArray._enabled = true;
875  glEnableClientState(GL_COLOR_ARRAY);
876  }
877  //if (_colorArray._pointer!=ptr || _colorArray._dirty)
878  {
879  _colorArray._pointer=ptr;
880  glColorPointer( size, type, stride, ptr );
881  }
882  _colorArray._lazy_disable = false;
883  _colorArray._dirty = false;
884  _colorArray._normalized = normalized;
885  }
886  #else
887  setVertexAttribPointer(_colorAlias._location, size, type, normalized, stride, ptr);
888  #endif
889  }
890 
893  inline void disableColorPointer()
894  {
895  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
896  if (_useVertexAttributeAliasing)
897  {
898  disableVertexAttribPointer(_colorAlias._location);
899  }
900  else
901  {
902  if (_colorArray._enabled || _colorArray._dirty)
903  {
904  _colorArray._lazy_disable = false;
905  _colorArray._enabled = false;
906  _colorArray._dirty = false;
907  glDisableClientState(GL_COLOR_ARRAY);
908  }
909  }
910  #else
911  disableVertexAttribPointer(_colorAlias._location);
912  #endif
913  }
914 
915  inline void dirtyColorPointer()
916  {
917  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
918  if (_useVertexAttributeAliasing)
919  {
920  dirtyVertexAttribPointer(_colorAlias._location);
921  }
922  else
923  {
924  _colorArray._pointer = 0;
925  _colorArray._dirty = true;
926  }
927  #else
928  dirtyVertexAttribPointer(_colorAlias._location);
929  #endif
930  }
931 
932 
933  inline bool isSecondaryColorSupported() const { return _isSecondaryColorSupportResolved?_isSecondaryColorSupported:computeSecondaryColorSupported(); }
934 
935 
937  inline void setSecondaryColorPointer(const Array* array)
938  {
939  if (array)
940  {
941  GLBufferObject* vbo = isVertexBufferObjectSupported() ? array->getOrCreateGLBufferObject(_contextID) : 0;
942  if (vbo)
943  {
944  bindVertexBufferObject(vbo);
945  setSecondaryColorPointer(array->getDataSize(),array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex())),array->getNormalize());
946  }
947  else
948  {
949  unbindVertexBufferObject();
950  setSecondaryColorPointer(array->getDataSize(),array->getDataType(),0,array->getDataPointer(),array->getNormalize());
951  }
952  }
953  }
954 
957  void setSecondaryColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_TRUE );
958 
962  {
963  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
964  if (_useVertexAttributeAliasing)
965  {
966  disableVertexAttribPointer(_secondaryColorAlias._location);
967  }
968  else
969  {
970  if (_secondaryColorArray._enabled || _secondaryColorArray._dirty)
971  {
972  _secondaryColorArray._lazy_disable = false;
973  _secondaryColorArray._enabled = false;
974  _secondaryColorArray._dirty = false;
975  if (isSecondaryColorSupported()) glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
976  }
977  }
978  #else
979  disableVertexAttribPointer(_secondaryColorAlias._location);
980  #endif
981  }
982 
984  {
985  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
986  if (_useVertexAttributeAliasing)
987  {
988  dirtyVertexAttribPointer(_secondaryColorAlias._location);
989  }
990  else
991  {
992  _secondaryColorArray._pointer = 0;
993  _secondaryColorArray._dirty = true;
994  }
995  #else
996  dirtyVertexAttribPointer(_secondaryColorAlias._location);
997  #endif
998  }
999 
1000  inline bool isFogCoordSupported() const { return _isFogCoordSupportResolved?_isFogCoordSupported:computeFogCoordSupported(); }
1001 
1002 
1004  inline void setFogCoordPointer(const Array* array)
1005  {
1006  if (array)
1007  {
1008  GLBufferObject* vbo = isVertexBufferObjectSupported() ? array->getOrCreateGLBufferObject(_contextID) : 0;
1009  if (vbo)
1010  {
1011  bindVertexBufferObject(vbo);
1012  setFogCoordPointer(array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex())),array->getNormalize());
1013  }
1014  else
1015  {
1016  unbindVertexBufferObject();
1017  setFogCoordPointer(array->getDataType(),0,array->getDataPointer(),array->getNormalize());
1018  }
1019  }
1020  }
1021 
1022 
1025  void setFogCoordPointer( GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE );
1026 
1030  {
1031  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
1032  if (_useVertexAttributeAliasing)
1033  {
1034  disableVertexAttribPointer(_fogCoordAlias._location);
1035  }
1036  else
1037  {
1038  if (_fogArray._enabled || _fogArray._dirty)
1039  {
1040  _fogArray._lazy_disable = false;
1041  _fogArray._enabled = false;
1042  _fogArray._dirty = false;
1043  if (isFogCoordSupported()) glDisableClientState(GL_FOG_COORDINATE_ARRAY);
1044  }
1045  }
1046  #else
1047  disableVertexAttribPointer(_fogCoordAlias._location);
1048  #endif
1049  }
1050 
1051  inline void dirtyFogCoordPointer()
1052  {
1053  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
1054  if (_useVertexAttributeAliasing)
1055  {
1056  dirtyVertexAttribPointer(_fogCoordAlias._location);
1057  }
1058  else
1059  {
1060  _fogArray._pointer = 0;
1061  _fogArray._dirty = true;
1062  }
1063  #else
1064  dirtyVertexAttribPointer(_fogCoordAlias._location);
1065  #endif
1066  }
1067 
1068 
1069 
1071  inline void setTexCoordPointer(unsigned int unit, const Array* array)
1072  {
1073  if (array)
1074  {
1075  GLBufferObject* vbo = isVertexBufferObjectSupported() ? array->getOrCreateGLBufferObject(_contextID) : 0;
1076  if (vbo)
1077  {
1078  bindVertexBufferObject(vbo);
1079  setTexCoordPointer(unit, array->getDataSize(),array->getDataType(),0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex())),array->getNormalize());
1080  }
1081  else
1082  {
1083  unbindVertexBufferObject();
1084  setTexCoordPointer(unit, array->getDataSize(),array->getDataType(),0,array->getDataPointer(),array->getNormalize());
1085  }
1086  }
1087  }
1088 
1091  inline void setTexCoordPointer( unsigned int unit,
1092  GLint size, GLenum type,
1093  GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE )
1094  {
1095  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
1096  if (_useVertexAttributeAliasing)
1097  {
1098  setVertexAttribPointer(_texCoordAliasList[unit]._location, size, type, normalized, stride, ptr);
1099  }
1100  else
1101  {
1102  if (setClientActiveTextureUnit(unit))
1103  {
1104  if ( unit >= _texCoordArrayList.size()) _texCoordArrayList.resize(unit+1);
1105  EnabledArrayPair& eap = _texCoordArrayList[unit];
1106 
1107  if (!eap._enabled || eap._dirty)
1108  {
1109  eap._enabled = true;
1110  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
1111  }
1112  //if (eap._pointer!=ptr || eap._dirty)
1113  {
1114  glTexCoordPointer( size, type, stride, ptr );
1115  eap._pointer = ptr;
1116  }
1117  eap._lazy_disable = false;
1118  eap._dirty = false;
1119  eap._normalized = normalized;
1120  }
1121  }
1122  #else
1123  setVertexAttribPointer(_texCoordAliasList[unit]._location, size, type, normalized, stride, ptr);
1124  #endif
1125  }
1126 
1129  inline void disableTexCoordPointer( unsigned int unit )
1130  {
1131  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
1132  if (_useVertexAttributeAliasing)
1133  {
1134  disableVertexAttribPointer(_texCoordAliasList[unit]._location);
1135  }
1136  else
1137  {
1138  if ( unit >= _texCoordArrayList.size()) _texCoordArrayList.resize(unit+1);
1139  EnabledArrayPair& eap = _texCoordArrayList[unit];
1140 
1141  if (eap._enabled || eap._dirty)
1142  {
1143  if(setClientActiveTextureUnit(unit))
1144  {
1145  eap._lazy_disable = false;
1146  eap._enabled = false;
1147  eap._dirty = false;
1148  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1149  }
1150  }
1151  }
1152  #else
1153  disableVertexAttribPointer(_texCoordAliasList[unit]._location);
1154  #endif
1155  }
1156 
1157  inline void dirtyTexCoordPointer( unsigned int unit )
1158  {
1159  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
1160  if (_useVertexAttributeAliasing)
1161  {
1162  dirtyVertexAttribPointer(_texCoordAliasList[unit]._location);
1163  }
1164  else
1165  {
1166  if ( unit >= _texCoordArrayList.size()) return; // _texCoordArrayList.resize(unit+1);
1167  EnabledArrayPair& eap = _texCoordArrayList[unit];
1168  eap._pointer = 0;
1169  eap._dirty = true;
1170  }
1171  #else
1172  dirtyVertexAttribPointer(_texCoordAliasList[unit]._location);
1173  #endif
1174  }
1175 
1176 
1177  inline void disableTexCoordPointersAboveAndIncluding( unsigned int unit )
1178  {
1179  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
1180  if (_useVertexAttributeAliasing)
1181  {
1182  disableVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location);
1183  }
1184  else
1185  {
1186  while (unit<_texCoordArrayList.size())
1187  {
1188  EnabledArrayPair& eap = _texCoordArrayList[unit];
1189  if (eap._enabled || eap._dirty)
1190  {
1191  if (setClientActiveTextureUnit(unit))
1192  {
1193  eap._lazy_disable = false;
1194  eap._enabled = false;
1195  eap._dirty = false;
1196  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1197  }
1198  }
1199  ++unit;
1200  }
1201  }
1202  #else
1203  disableVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location);
1204  #endif
1205  }
1206 
1207  inline void dirtyTexCoordPointersAboveAndIncluding( unsigned int unit )
1208  {
1209  #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
1210  if (_useVertexAttributeAliasing)
1211  {
1212  dirtyVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location);
1213  }
1214  else
1215  {
1216  while (unit<_texCoordArrayList.size())
1217  {
1218  EnabledArrayPair& eap = _texCoordArrayList[unit];
1219  eap._pointer = 0;
1220  eap._dirty = true;
1221  ++unit;
1222  }
1223  }
1224  #else
1225  dirtyVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location);
1226  #endif
1227  }
1228 
1229 
1231  inline GLint getMaxTextureCoords() const { return _glMaxTextureCoords; }
1232 
1234  inline GLint getMaxTextureUnits() const { return _glMaxTextureUnits; }
1235 
1236 
1240  inline bool setActiveTextureUnit( unsigned int unit );
1241 
1243  unsigned int getActiveTextureUnit() const { return _currentActiveTextureUnit; }
1244 
1248  bool setClientActiveTextureUnit( unsigned int unit );
1249 
1251  unsigned int getClientActiveTextureUnit() const { return _currentClientActiveTextureUnit; }
1252 
1254  inline void setVertexAttribPointer(unsigned int unit, const Array* array)
1255  {
1256  if (array)
1257  {
1258  GLBufferObject* vbo = isVertexBufferObjectSupported() ? array->getOrCreateGLBufferObject(_contextID) : 0;
1259  if (vbo)
1260  {
1261  bindVertexBufferObject(vbo);
1262  setVertexAttribPointer(unit, array->getDataSize(),array->getDataType(),array->getNormalize(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex())));
1263  }
1264  else
1265  {
1266  unbindVertexBufferObject();
1267  setVertexAttribPointer(unit, array->getDataSize(),array->getDataType(),array->getNormalize(),0,array->getDataPointer());
1268  }
1269  }
1270  }
1271 
1273  inline void setVertexAttribLPointer(unsigned int unit, const Array* array)
1274  {
1275  if (array)
1276  {
1277  GLBufferObject* vbo = array->getOrCreateGLBufferObject(_contextID);
1278  if (vbo)
1279  {
1280  bindVertexBufferObject(vbo);
1281  setVertexAttribLPointer(unit, array->getDataSize(),array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex())));
1282  }
1283  else
1284  {
1285  unbindVertexBufferObject();
1286  setVertexAttribLPointer(unit, array->getDataSize(),array->getDataType(),0,array->getDataPointer());
1287  }
1288  }
1289  }
1290 
1292  inline void setVertexAttribIPointer(unsigned int unit, const Array* array)
1293  {
1294  if (array)
1295  {
1296  GLBufferObject* vbo = array->getOrCreateGLBufferObject(_contextID);
1297  if (vbo)
1298  {
1299  bindVertexBufferObject(vbo);
1300  setVertexAttribIPointer(unit, array->getDataSize(),array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex())));
1301  }
1302  else
1303  {
1304  unbindVertexBufferObject();
1305  setVertexAttribIPointer(unit, array->getDataSize(),array->getDataType(),0,array->getDataPointer());
1306  }
1307  }
1308  }
1309 
1312  void setVertexAttribPointer( unsigned int index,
1313  GLint size, GLenum type, GLboolean normalized,
1314  GLsizei stride, const GLvoid *ptr );
1315 
1318  void setVertexAttribIPointer( unsigned int index,
1319  GLint size, GLenum type,
1320  GLsizei stride, const GLvoid *ptr );
1321 
1324  void setVertexAttribLPointer( unsigned int index,
1325  GLint size, GLenum type,
1326  GLsizei stride, const GLvoid *ptr );
1327 
1330  void disableVertexAttribPointer( unsigned int index );
1331 
1332  void disableVertexAttribPointersAboveAndIncluding( unsigned int index );
1333 
1334  inline void dirtyVertexAttribPointer( unsigned int index )
1335  {
1336  if (index<_vertexAttribArrayList.size())
1337  {
1338  EnabledArrayPair& eap = _vertexAttribArrayList[index];
1339  eap._pointer = 0;
1340  eap._dirty = true;
1341  }
1342  }
1343 
1344  inline void dirtyVertexAttribPointersAboveAndIncluding( unsigned int index )
1345  {
1346  while (index<_vertexAttribArrayList.size())
1347  {
1348  EnabledArrayPair& eap = _vertexAttribArrayList[index];
1349  eap._pointer = 0;
1350  eap._dirty = true;
1351  ++index;
1352  }
1353  }
1354 
1355  bool isVertexBufferObjectSupported() const { return _isVertexBufferObjectSupportResolved?_isVertexBufferObjectSupported:computeVertexBufferObjectSupported(); }
1356 
1357 
1359  {
1360  if (_lastAppliedProgramObject!=program)
1361  {
1362  _lastAppliedProgramObject = program;
1363  }
1364  }
1365  inline const Program::PerContextProgram* getLastAppliedProgramObject() const { return _lastAppliedProgramObject; }
1366 
1367  inline GLint getUniformLocation( unsigned int uniformNameID ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getUniformLocation(uniformNameID) : -1; }
1376  inline GLint getUniformLocation( const std::string & uniformName ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getUniformLocation(uniformName) : -1; }
1377  inline GLint getAttribLocation( const std::string& name ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getAttribLocation(name) : -1; }
1378 
1379  typedef std::pair<const StateAttribute*,StateAttribute::OverrideValue> AttributePair;
1380  typedef std::vector<AttributePair> AttributeVec;
1381 
1382  AttributeVec& getAttributeVec( const osg::StateAttribute* attribute )
1383  {
1384  AttributeStack& as = _attributeMap[ attribute->getTypeMemberPair() ];
1385  return as.attributeVec;
1386  }
1387 
1389  inline void setFrameStamp(FrameStamp* fs) { _frameStamp = fs; }
1390 
1392  inline FrameStamp* getFrameStamp() { return _frameStamp.get(); }
1393 
1395  inline const FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
1396 
1397 
1401  inline void setDisplaySettings(DisplaySettings* vs) { _displaySettings = vs; }
1402 
1404  inline const DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
1405 
1406 
1407 
1409  void setAbortRenderingPtr(bool* abortPtr) { _abortRenderingPtr = abortPtr; }
1410 
1413  bool getAbortRendering() const { return _abortRenderingPtr!=0?(*_abortRenderingPtr):false; }
1414 
1415 
1417  {
1418  virtual void completed(osg::State*) = 0;
1419  };
1420 
1422  void setDynamicObjectRenderingCompletedCallback(DynamicObjectRenderingCompletedCallback* cb){ _completeDynamicObjectRenderingCallback = cb; }
1423 
1425  DynamicObjectRenderingCompletedCallback* getDynamicObjectRenderingCompletedCallback() { return _completeDynamicObjectRenderingCallback.get(); }
1426 
1428  void setDynamicObjectCount(unsigned int count, bool callCallbackOnZero = false)
1429  {
1430  if (_dynamicObjectCount != count)
1431  {
1432  _dynamicObjectCount = count;
1433  if (_dynamicObjectCount==0 && callCallbackOnZero && _completeDynamicObjectRenderingCallback.valid())
1434  {
1435  _completeDynamicObjectRenderingCallback->completed(this);
1436  }
1437  }
1438  }
1439 
1441  unsigned int getDynamicObjectCount() const { return _dynamicObjectCount; }
1442 
1446  {
1447  --_dynamicObjectCount;
1448  if (_dynamicObjectCount==0 && _completeDynamicObjectRenderingCallback.valid())
1449  {
1450  _completeDynamicObjectRenderingCallback->completed(this);
1451  }
1452  }
1453 
1454  void setMaxTexturePoolSize(unsigned int size);
1455  unsigned int getMaxTexturePoolSize() const { return _maxTexturePoolSize; }
1456 
1457  void setMaxBufferObjectPoolSize(unsigned int size);
1458  unsigned int getMaxBufferObjectPoolSize() const { return _maxBufferObjectPoolSize; }
1459 
1460 
1462  {
1473  ONCE_PER_ATTRIBUTE
1474  };
1475 
1477  void setCheckForGLErrors(CheckForGLErrors check) { _checkGLErrors = check; }
1478 
1480  CheckForGLErrors getCheckForGLErrors() const { return _checkGLErrors; }
1481 
1482  bool checkGLErrors(const char* str) const;
1483  bool checkGLErrors(StateAttribute::GLMode mode) const;
1484  bool checkGLErrors(const StateAttribute* attribute) const;
1485 
1487  void print(std::ostream& fout) const;
1488 
1490  void initializeExtensionProcs();
1491 
1493  inline GLBeginEndAdapter& getGLBeginEndAdapter() { return _glBeginEndAdapter; }
1494 
1496  inline ArrayDispatchers& getArrayDispatchers() { return _arrayDispatchers; }
1497 
1498 
1500  inline void setGraphicsCostEstimator(GraphicsCostEstimator* gce) { _graphicsCostEstimator = gce; }
1501 
1503  inline GraphicsCostEstimator* getGraphicsCostEstimator() { return _graphicsCostEstimator.get(); }
1504 
1506  inline const GraphicsCostEstimator* getGraphicsCostEstimator() const { return _graphicsCostEstimator.get(); }
1507 
1508 
1509 
1514  Timer_t getStartTick() const { return _startTick; }
1515  void setStartTick(Timer_t tick) { _startTick = tick; }
1516  Timer_t getGpuTick() const { return _gpuTick; }
1517 
1518  double getGpuTime() const
1519  {
1520  return osg::Timer::instance()->delta_s(_startTick, _gpuTick);
1521  }
1522  GLuint64 getGpuTimestamp() const { return _gpuTimestamp; }
1523 
1524  void setGpuTimestamp(Timer_t tick, GLuint64 timestamp)
1525  {
1526  _gpuTick = tick;
1527  _gpuTimestamp = timestamp;
1528  }
1529  int getTimestampBits() const { return _timestampBits; }
1530  void setTimestampBits(int bits) { _timestampBits = bits; }
1531 
1533  virtual void frameCompleted();
1534 
1535 
1536  struct ModeStack
1537  {
1538  typedef std::vector<StateAttribute::GLModeValue> ValueVec;
1539 
1541  {
1542  valid = true;
1543  changed = false;
1544  last_applied_value = false;
1545  global_default_value = false;
1546  }
1547 
1548  void print(std::ostream& fout) const;
1549 
1550  bool valid;
1551  bool changed;
1554  ValueVec valueVec;
1555  };
1556 
1558  {
1560  {
1561  changed = false;
1562  last_applied_attribute = 0L;
1563  last_applied_shadercomponent = 0L;
1564  global_default_attribute = 0L;
1565 
1566  }
1567 
1568  void print(std::ostream& fout) const;
1569 
1571  bool changed;
1575  AttributeVec attributeVec;
1576  };
1577 
1578 
1580  {
1581  typedef std::pair<const Uniform*,StateAttribute::OverrideValue> UniformPair;
1582  typedef std::vector<UniformPair> UniformVec;
1583 
1585 
1586  void print(std::ostream& fout) const;
1587 
1588  UniformVec uniformVec;
1589  };
1590 
1592  {
1593  typedef std::vector<StateSet::DefinePair> DefineVec;
1594 
1596  changed(false) {}
1597 
1598  void print(std::ostream& fout) const;
1599 
1600  bool changed;
1601  DefineVec defineVec;
1602  };
1603 
1604  struct DefineMap
1605  {
1607  changed(false) {}
1608 
1609  typedef std::map<std::string, DefineStack> DefineStackMap;
1610  DefineStackMap map;
1611  bool changed;
1613 
1614  bool updateCurrentDefines();
1615 
1616  };
1617 
1618  typedef std::map<StateAttribute::GLMode,ModeStack> ModeMap;
1619  typedef std::vector<ModeMap> TextureModeMapList;
1620 
1621  typedef std::map<StateAttribute::TypeMemberPair,AttributeStack> AttributeMap;
1622  typedef std::vector<AttributeMap> TextureAttributeMapList;
1623 
1624  typedef std::map<std::string, UniformStack> UniformMap;
1625 
1626 
1627  typedef std::vector< ref_ptr<const Matrix> > MatrixStack;
1628 
1629  inline const ModeMap& getModeMap() const {return _modeMap;}
1630  inline const AttributeMap& getAttributeMap() const {return _attributeMap;}
1631  inline const UniformMap& getUniformMap() const {return _uniformMap;}
1632  inline DefineMap& getDefineMap() {return _defineMap;}
1633  inline const DefineMap& getDefineMap() const {return _defineMap;}
1634  inline const TextureModeMapList& getTextureModeMapList() const {return _textureModeMapList;}
1635  inline const TextureAttributeMapList& getTextureAttributeMapList() const {return _textureAttributeMapList;}
1636 
1637  std::string getDefineString(const osg::ShaderDefines& shaderDefines);
1638  bool supportsShaderRequirements(const osg::ShaderDefines& shaderRequirements);
1639  bool supportsShaderRequirement(const std::string& shaderRequirement);
1640 
1641  protected:
1642 
1643  virtual ~State();
1644 
1646  unsigned int _contextID;
1647 
1653 
1655 
1661 
1667 
1669 
1671 
1674 
1675 
1682  VertexAttribAliasList _texCoordAliasList;
1683 
1685 
1686  void setUpVertexAttribAlias(VertexAttribAlias& alias, GLuint location, const std::string glName, const std::string osgName, const std::string& declaration);
1696  inline bool applyMode(StateAttribute::GLMode mode,bool enabled,ModeStack& ms)
1697  {
1698  if (ms.valid && ms.last_applied_value != enabled)
1699  {
1700  ms.last_applied_value = enabled;
1701 
1702  if (enabled) glEnable(mode);
1703  else glDisable(mode);
1704 
1705  if (_checkGLErrors==ONCE_PER_ATTRIBUTE) checkGLErrors(mode);
1706 
1707  return true;
1708  }
1709  else
1710  return false;
1711  }
1712 
1713  inline bool applyModeOnTexUnit(unsigned int unit,StateAttribute::GLMode mode,bool enabled,ModeStack& ms)
1714  {
1715  if (ms.valid && ms.last_applied_value != enabled)
1716  {
1717  if (setActiveTextureUnit(unit))
1718  {
1719  ms.last_applied_value = enabled;
1720 
1721  if (enabled) glEnable(mode);
1722  else glDisable(mode);
1723 
1724  if (_checkGLErrors==ONCE_PER_ATTRIBUTE) checkGLErrors(mode);
1725 
1726  return true;
1727  }
1728  else
1729  return false;
1730  }
1731  else
1732  return false;
1733  }
1734 
1736  inline bool applyAttribute(const StateAttribute* attribute,AttributeStack& as)
1737  {
1738  if (as.last_applied_attribute != attribute)
1739  {
1740  if (!as.global_default_attribute.valid()) as.global_default_attribute = dynamic_cast<StateAttribute*>(attribute->cloneType());
1741 
1742  as.last_applied_attribute = attribute;
1743  attribute->apply(*this);
1744 
1745  const ShaderComponent* sc = attribute->getShaderComponent();
1746  if (as.last_applied_shadercomponent != sc)
1747  {
1749  _shaderCompositionDirty = true;
1750  }
1751 
1752  if (_checkGLErrors==ONCE_PER_ATTRIBUTE) checkGLErrors(attribute);
1753 
1754  return true;
1755  }
1756  else
1757  return false;
1758  }
1759 
1760  inline bool applyAttributeOnTexUnit(unsigned int unit,const StateAttribute* attribute,AttributeStack& as)
1761  {
1762  if (as.last_applied_attribute != attribute)
1763  {
1764  if (setActiveTextureUnit(unit))
1765  {
1766  if (!as.global_default_attribute.valid()) as.global_default_attribute = dynamic_cast<StateAttribute*>(attribute->cloneType());
1767 
1768  as.last_applied_attribute = attribute;
1769  attribute->apply(*this);
1770 
1771  const ShaderComponent* sc = attribute->getShaderComponent();
1772  if (as.last_applied_shadercomponent != sc)
1773  {
1775  _shaderCompositionDirty = true;
1776  }
1777 
1778  if (_checkGLErrors==ONCE_PER_ATTRIBUTE) checkGLErrors(attribute);
1779 
1780  return true;
1781  }
1782  else
1783  return false;
1784  }
1785  else
1786  return false;
1787  }
1788 
1789 
1791  {
1793  {
1795  if (as.global_default_attribute.valid())
1796  {
1797  as.global_default_attribute->apply(*this);
1798  const ShaderComponent* sc = as.global_default_attribute->getShaderComponent();
1799  if (as.last_applied_shadercomponent != sc)
1800  {
1802  _shaderCompositionDirty = true;
1803  }
1804 
1805  if (_checkGLErrors==ONCE_PER_ATTRIBUTE) checkGLErrors(as.global_default_attribute.get());
1806  }
1807  return true;
1808  }
1809  else
1810  return false;
1811  }
1812 
1813  inline bool applyGlobalDefaultAttributeOnTexUnit(unsigned int unit,AttributeStack& as)
1814  {
1816  {
1817  if (setActiveTextureUnit(unit))
1818  {
1820  if (as.global_default_attribute.valid())
1821  {
1822  as.global_default_attribute->apply(*this);
1823  const ShaderComponent* sc = as.global_default_attribute->getShaderComponent();
1824  if (as.last_applied_shadercomponent != sc)
1825  {
1827  _shaderCompositionDirty = true;
1828  }
1829  if (_checkGLErrors==ONCE_PER_ATTRIBUTE) checkGLErrors(as.global_default_attribute.get());
1830  }
1831  return true;
1832  }
1833  else
1834  return false;
1835  }
1836  else
1837  return false;
1838  }
1839 
1840  ModeMap _modeMap;
1841  AttributeMap _attributeMap;
1842  UniformMap _uniformMap;
1844 
1845  TextureModeMapList _textureModeMapList;
1846  TextureAttributeMapList _textureAttributeMapList;
1847 
1849 
1850  StateSetStack _stateStateStack;
1851 
1852  unsigned int _maxTexturePoolSize;
1854 
1855 
1857  {
1858  EnabledArrayPair():_lazy_disable(false),_dirty(true),_enabled(false),_normalized(0),_pointer(0) {}
1859  EnabledArrayPair(const EnabledArrayPair& eap):_lazy_disable(eap._lazy_disable),_dirty(eap._dirty), _enabled(eap._enabled),_normalized(eap._normalized),_pointer(eap._pointer) {}
1860  EnabledArrayPair& operator = (const EnabledArrayPair& eap) { _lazy_disable = eap._lazy_disable;_dirty=eap._dirty; _enabled=eap._enabled; _normalized=eap._normalized;_pointer=eap._pointer; return *this; }
1861 
1863  bool _dirty;
1864  bool _enabled;
1865  GLboolean _normalized;
1866  const GLvoid* _pointer;
1867  };
1868 
1869  typedef std::vector<EnabledArrayPair> EnabledTexCoordArrayList;
1870  typedef std::vector<EnabledArrayPair> EnabledVertexAttribArrayList;
1871 
1877  EnabledTexCoordArrayList _texCoordArrayList;
1878  EnabledVertexAttribArrayList _vertexAttribArrayList;
1879 
1885 
1886 
1887  inline ModeMap& getOrCreateTextureModeMap(unsigned int unit)
1888  {
1889  if (unit>=_textureModeMapList.size()) _textureModeMapList.resize(unit+1);
1890  return _textureModeMapList[unit];
1891  }
1892 
1893 
1894  inline AttributeMap& getOrCreateTextureAttributeMap(unsigned int unit)
1895  {
1896  if (unit>=_textureAttributeMapList.size()) _textureAttributeMapList.resize(unit+1);
1897  return _textureAttributeMapList[unit];
1898  }
1899 
1900  inline void pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeList);
1901  inline void pushAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
1902  inline void pushUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList);
1903  inline void pushDefineList(DefineMap& defineMap,const StateSet::DefineList& defineList);
1904 
1905  inline void popModeList(ModeMap& modeMap,const StateSet::ModeList& modeList);
1906  inline void popAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
1907  inline void popUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList);
1908  inline void popDefineList(DefineMap& uniformMap,const StateSet::DefineList& defineList);
1909 
1910  inline void applyModeList(ModeMap& modeMap,const StateSet::ModeList& modeList);
1911  inline void applyAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
1912  inline void applyUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList);
1913  inline void applyDefineList(DefineMap& uniformMap,const StateSet::DefineList& defineList);
1914 
1915  inline void applyModeMap(ModeMap& modeMap);
1916  inline void applyAttributeMap(AttributeMap& attributeMap);
1917  inline void applyUniformMap(UniformMap& uniformMap);
1918 
1919  inline void applyModeListOnTexUnit(unsigned int unit,ModeMap& modeMap,const StateSet::ModeList& modeList);
1920  inline void applyAttributeListOnTexUnit(unsigned int unit,AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
1921 
1922  inline void applyModeMapOnTexUnit(unsigned int unit,ModeMap& modeMap);
1923  inline void applyAttributeMapOnTexUnit(unsigned int unit,AttributeMap& attributeMap);
1924 
1925  void haveAppliedMode(ModeMap& modeMap,StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
1926  void haveAppliedMode(ModeMap& modeMap,StateAttribute::GLMode mode);
1927  void haveAppliedAttribute(AttributeMap& attributeMap,const StateAttribute* attribute);
1928  void haveAppliedAttribute(AttributeMap& attributeMap,StateAttribute::Type type, unsigned int member);
1929  bool getLastAppliedMode(const ModeMap& modeMap,StateAttribute::GLMode mode) const;
1930  const StateAttribute* getLastAppliedAttribute(const AttributeMap& attributeMap,StateAttribute::Type type, unsigned int member) const;
1931 
1932  void loadModelViewMatrix();
1933 
1934 
1937  bool computeSecondaryColorSupported() const;
1938 
1940  mutable bool _isFogCoordSupported;
1941  bool computeFogCoordSupported() const;
1942 
1945  bool computeVertexBufferObjectSupported() const;
1946 
1947  typedef void (GL_APIENTRY * ActiveTextureProc) (GLenum texture);
1948  typedef void (GL_APIENTRY * FogCoordPointerProc) (GLenum type, GLsizei stride, const GLvoid *pointer);
1949  typedef void (GL_APIENTRY * SecondaryColorPointerProc) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
1950  typedef void (GL_APIENTRY * MultiTexCoord4fProc) (GLenum target, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1951  typedef void (GL_APIENTRY * VertexAttrib4fProc)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1952  typedef void (GL_APIENTRY * VertexAttrib4fvProc)(GLuint index, const GLfloat *v);
1953  typedef void (GL_APIENTRY * VertexAttribPointerProc) (unsigned int, GLint, GLenum, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
1954  typedef void (GL_APIENTRY * VertexAttribIPointerProc) (unsigned int, GLint, GLenum, GLsizei stride, const GLvoid *pointer);
1955  typedef void (GL_APIENTRY * VertexAttribLPointerProc) (unsigned int, GLint, GLenum, GLsizei stride, const GLvoid *pointer);
1956  typedef void (GL_APIENTRY * EnableVertexAttribProc) (unsigned int);
1957  typedef void (GL_APIENTRY * DisableVertexAttribProc) (unsigned int);
1958  typedef void (GL_APIENTRY * BindBufferProc) (GLenum target, GLuint buffer);
1959 
1960  typedef void (GL_APIENTRY * DrawArraysInstancedProc)( GLenum mode, GLint first, GLsizei count, GLsizei primcount );
1961  typedef void (GL_APIENTRY * DrawElementsInstancedProc)( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount );
1962 
1966  ActiveTextureProc _glClientActiveTexture;
1967  ActiveTextureProc _glActiveTexture;
1968  MultiTexCoord4fProc _glMultiTexCoord4f;
1969  VertexAttrib4fProc _glVertexAttrib4f;
1970  VertexAttrib4fvProc _glVertexAttrib4fv;
1971  FogCoordPointerProc _glFogCoordPointer;
1972  SecondaryColorPointerProc _glSecondaryColorPointer;
1973  VertexAttribPointerProc _glVertexAttribPointer;
1974  VertexAttribIPointerProc _glVertexAttribIPointer;
1975  VertexAttribLPointerProc _glVertexAttribLPointer;
1976  EnableVertexAttribProc _glEnableVertexAttribArray;
1977  DisableVertexAttribProc _glDisableVertexAttribArray;
1978  BindBufferProc _glBindBuffer;
1979  DrawArraysInstancedProc _glDrawArraysInstanced;
1980  DrawElementsInstancedProc _glDrawElementsInstanced;
1981 
1983 
1984  unsigned int _dynamicObjectCount;
1986 
1989 
1991 
1994  GLuint64 _gpuTimestamp;
1996 };
1997 
1998 inline void State::pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
1999 {
2000  for(StateSet::ModeList::const_iterator mitr=modeList.begin();
2001  mitr!=modeList.end();
2002  ++mitr)
2003  {
2004  // get the mode stack for incoming GLmode {mitr->first}.
2005  ModeStack& ms = modeMap[mitr->first];
2006  if (ms.valueVec.empty())
2007  {
2008  // first pair so simply push incoming pair to back.
2009  ms.valueVec.push_back(mitr->second);
2010  }
2011  else if ((ms.valueVec.back() & StateAttribute::OVERRIDE) && !(mitr->second & StateAttribute::PROTECTED)) // check the existing override flag
2012  {
2013  // push existing back since override keeps the previous value.
2014  ms.valueVec.push_back(ms.valueVec.back());
2015  }
2016  else
2017  {
2018  // no override on so simply push incoming pair to back.
2019  ms.valueVec.push_back(mitr->second);
2020  }
2021  ms.changed = true;
2022  }
2023 }
2024 
2025 inline void State::pushAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
2026 {
2027  for(StateSet::AttributeList::const_iterator aitr=attributeList.begin();
2028  aitr!=attributeList.end();
2029  ++aitr)
2030  {
2031  // get the attribute stack for incoming type {aitr->first}.
2032  AttributeStack& as = attributeMap[aitr->first];
2033  if (as.attributeVec.empty())
2034  {
2035  // first pair so simply push incoming pair to back.
2036  as.attributeVec.push_back(
2037  AttributePair(aitr->second.first.get(),aitr->second.second));
2038  }
2039  else if ((as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag
2040  {
2041  // push existing back since override keeps the previous value.
2042  as.attributeVec.push_back(as.attributeVec.back());
2043  }
2044  else
2045  {
2046  // no override on so simply push incoming pair to back.
2047  as.attributeVec.push_back(
2048  AttributePair(aitr->second.first.get(),aitr->second.second));
2049  }
2050  as.changed = true;
2051  }
2052 }
2053 
2054 
2055 inline void State::pushUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList)
2056 {
2057  for(StateSet::UniformList::const_iterator aitr=uniformList.begin();
2058  aitr!=uniformList.end();
2059  ++aitr)
2060  {
2061  // get the attribute stack for incoming type {aitr->first}.
2062  UniformStack& us = uniformMap[aitr->first];
2063  if (us.uniformVec.empty())
2064  {
2065  // first pair so simply push incoming pair to back.
2066  us.uniformVec.push_back(
2067  UniformStack::UniformPair(aitr->second.first.get(),aitr->second.second));
2068  }
2069  else if ((us.uniformVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag
2070  {
2071  // push existing back since override keeps the previous value.
2072  us.uniformVec.push_back(us.uniformVec.back());
2073  }
2074  else
2075  {
2076  // no override on so simply push incoming pair to back.
2077  us.uniformVec.push_back(
2078  UniformStack::UniformPair(aitr->second.first.get(),aitr->second.second));
2079  }
2080  }
2081 }
2082 
2083 inline void State::pushDefineList(DefineMap& defineMap,const StateSet::DefineList& defineList)
2084 {
2085  for(StateSet::DefineList::const_iterator aitr=defineList.begin();
2086  aitr!=defineList.end();
2087  ++aitr)
2088  {
2089  // get the attribute stack for incoming type {aitr->first}.
2090  DefineStack& ds = defineMap.map[aitr->first];
2092  if (dv.empty())
2093  {
2094  // first pair so simply push incoming pair to back.
2095  dv.push_back(StateSet::DefinePair(aitr->second.first,aitr->second.second));
2096 
2097  ds.changed = true;
2098  defineMap.changed = true;
2099  }
2100  else if ((ds.defineVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag
2101  {
2102  // push existing back since override keeps the previous value.
2103  ds.defineVec.push_back(ds.defineVec.back());
2104  }
2105  else
2106  {
2107  // no override on so simply push incoming pair to back.
2108  dv.push_back(StateSet::DefinePair(aitr->second.first,aitr->second.second));
2109 
2110  // if the back of the stack has changed since the last then mark it as changed.
2111  bool changed = (dv[dv.size()-2].first==dv[dv.size()-1].first);
2112  if (changed)
2113  {
2114  ds.changed = true;
2115  defineMap.changed = true;
2116  }
2117  }
2118  }
2119 }
2120 
2121 inline void State::popModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
2122 {
2123  for(StateSet::ModeList::const_iterator mitr=modeList.begin();
2124  mitr!=modeList.end();
2125  ++mitr)
2126  {
2127  // get the mode stack for incoming GLmode {mitr->first}.
2128  ModeStack& ms = modeMap[mitr->first];
2129  if (!ms.valueVec.empty())
2130  {
2131  ms.valueVec.pop_back();
2132  }
2133  ms.changed = true;
2134  }
2135 }
2136 
2137 inline void State::popAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
2138 {
2139  for(StateSet::AttributeList::const_iterator aitr=attributeList.begin();
2140  aitr!=attributeList.end();
2141  ++aitr)
2142  {
2143  // get the attribute stack for incoming type {aitr->first}.
2144  AttributeStack& as = attributeMap[aitr->first];
2145  if (!as.attributeVec.empty())
2146  {
2147  as.attributeVec.pop_back();
2148  }
2149  as.changed = true;
2150  }
2151 }
2152 
2153 inline void State::popUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList)
2154 {
2155  for(StateSet::UniformList::const_iterator aitr=uniformList.begin();
2156  aitr!=uniformList.end();
2157  ++aitr)
2158  {
2159  // get the attribute stack for incoming type {aitr->first}.
2160  UniformStack& us = uniformMap[aitr->first];
2161  if (!us.uniformVec.empty())
2162  {
2163  us.uniformVec.pop_back();
2164  }
2165  }
2166 }
2167 
2168 inline void State::popDefineList(DefineMap& defineMap,const StateSet::DefineList& defineList)
2169 {
2170  for(StateSet::DefineList::const_iterator aitr=defineList.begin();
2171  aitr!=defineList.end();
2172  ++aitr)
2173  {
2174  // get the attribute stack for incoming type {aitr->first}.
2175  DefineStack& ds = defineMap.map[aitr->first];
2177  if (!dv.empty())
2178  {
2179  // if the stack has less than 2 entries or new back vs old back are different then mark the DefineStack as changed
2180  if ((dv.size()<2) || (dv[dv.size()-2].first!=dv.back().first))
2181  {
2182  ds.changed = true;
2183  defineMap.changed = true;
2184  }
2185  dv.pop_back();
2186  }
2187  }
2188 }
2189 
2190 inline void State::applyModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
2191 {
2192  StateSet::ModeList::const_iterator ds_mitr = modeList.begin();
2193  ModeMap::iterator this_mitr=modeMap.begin();
2194 
2195  while (this_mitr!=modeMap.end() && ds_mitr!=modeList.end())
2196  {
2197  if (this_mitr->first<ds_mitr->first)
2198  {
2199 
2200  // note GLMode = this_mitr->first
2201  ModeStack& ms = this_mitr->second;
2202  if (ms.changed)
2203  {
2204  ms.changed = false;
2205  if (!ms.valueVec.empty())
2206  {
2207  bool new_value = ms.valueVec.back() & StateAttribute::ON;
2208  applyMode(this_mitr->first,new_value,ms);
2209  }
2210  else
2211  {
2212  // assume default of disabled.
2213  applyMode(this_mitr->first,ms.global_default_value,ms);
2214 
2215  }
2216 
2217  }
2218 
2219  ++this_mitr;
2220 
2221  }
2222  else if (ds_mitr->first<this_mitr->first)
2223  {
2224 
2225  // ds_mitr->first is a new mode, therefore
2226  // need to insert a new mode entry for ds_mistr->first.
2227  ModeStack& ms = modeMap[ds_mitr->first];
2228 
2229  bool new_value = ds_mitr->second & StateAttribute::ON;
2230  applyMode(ds_mitr->first,new_value,ms);
2231 
2232  // will need to disable this mode on next apply so set it to changed.
2233  ms.changed = true;
2234 
2235  ++ds_mitr;
2236 
2237  }
2238  else
2239  {
2240  // this_mitr & ds_mitr refer to the same mode, check the override
2241  // if any otherwise just apply the incoming mode.
2242 
2243  ModeStack& ms = this_mitr->second;
2244 
2245  if (!ms.valueVec.empty() && (ms.valueVec.back() & StateAttribute::OVERRIDE) && !(ds_mitr->second & StateAttribute::PROTECTED))
2246  {
2247  // override is on, just treat as a normal apply on modes.
2248 
2249  if (ms.changed)
2250  {
2251  ms.changed = false;
2252  bool new_value = ms.valueVec.back() & StateAttribute::ON;
2253  applyMode(this_mitr->first,new_value,ms);
2254 
2255  }
2256  }
2257  else
2258  {
2259  // no override on or no previous entry, therefore consider incoming mode.
2260  bool new_value = ds_mitr->second & StateAttribute::ON;
2261  if (applyMode(ds_mitr->first,new_value,ms))
2262  {
2263  ms.changed = true;
2264  }
2265  }
2266 
2267  ++this_mitr;
2268  ++ds_mitr;
2269  }
2270  }
2271 
2272  // iterator over the remaining state modes to apply any previous changes.
2273  for(;
2274  this_mitr!=modeMap.end();
2275  ++this_mitr)
2276  {
2277  // note GLMode = this_mitr->first
2278  ModeStack& ms = this_mitr->second;
2279  if (ms.changed)
2280  {
2281  ms.changed = false;
2282  if (!ms.valueVec.empty())
2283  {
2284  bool new_value = ms.valueVec.back() & StateAttribute::ON;
2285  applyMode(this_mitr->first,new_value,ms);
2286  }
2287  else
2288  {
2289  // assume default of disabled.
2290  applyMode(this_mitr->first,ms.global_default_value,ms);
2291 
2292  }
2293 
2294  }
2295  }
2296 
2297  // iterator over the remaining incoming modes to apply any new mode.
2298  for(;
2299  ds_mitr!=modeList.end();
2300  ++ds_mitr)
2301  {
2302  ModeStack& ms = modeMap[ds_mitr->first];
2303 
2304  bool new_value = ds_mitr->second & StateAttribute::ON;
2305  applyMode(ds_mitr->first,new_value,ms);
2306 
2307  // will need to disable this mode on next apply so set it to changed.
2308  ms.changed = true;
2309  }
2310 }
2311 
2312 inline void State::applyModeListOnTexUnit(unsigned int unit,ModeMap& modeMap,const StateSet::ModeList& modeList)
2313 {
2314  StateSet::ModeList::const_iterator ds_mitr = modeList.begin();
2315  ModeMap::iterator this_mitr=modeMap.begin();
2316 
2317  while (this_mitr!=modeMap.end() && ds_mitr!=modeList.end())
2318  {
2319  if (this_mitr->first<ds_mitr->first)
2320  {
2321 
2322  // note GLMode = this_mitr->first
2323  ModeStack& ms = this_mitr->second;
2324  if (ms.changed)
2325  {
2326  ms.changed = false;
2327  if (!ms.valueVec.empty())
2328  {
2329  bool new_value = ms.valueVec.back() & StateAttribute::ON;
2330  applyModeOnTexUnit(unit,this_mitr->first,new_value,ms);
2331  }
2332  else
2333  {
2334  // assume default of disabled.
2335  applyModeOnTexUnit(unit,this_mitr->first,ms.global_default_value,ms);
2336 
2337  }
2338 
2339  }
2340 
2341  ++this_mitr;
2342 
2343  }
2344  else if (ds_mitr->first<this_mitr->first)
2345  {
2346 
2347  // ds_mitr->first is a new mode, therefore
2348  // need to insert a new mode entry for ds_mistr->first.
2349  ModeStack& ms = modeMap[ds_mitr->first];
2350 
2351  bool new_value = ds_mitr->second & StateAttribute::ON;
2352  applyModeOnTexUnit(unit,ds_mitr->first,new_value,ms);
2353 
2354  // will need to disable this mode on next apply so set it to changed.
2355  ms.changed = true;
2356 
2357  ++ds_mitr;
2358 
2359  }
2360  else
2361  {
2362  // this_mitr & ds_mitr refer to the same mode, check the override
2363  // if any otherwise just apply the incoming mode.
2364 
2365  ModeStack& ms = this_mitr->second;
2366 
2367  if (!ms.valueVec.empty() && (ms.valueVec.back() & StateAttribute::OVERRIDE) && !(ds_mitr->second & StateAttribute::PROTECTED))
2368  {
2369  // override is on, just treat as a normal apply on modes.
2370 
2371  if (ms.changed)
2372  {
2373  ms.changed = false;
2374  bool new_value = ms.valueVec.back() & StateAttribute::ON;
2375  applyModeOnTexUnit(unit,this_mitr->first,new_value,ms);
2376 
2377  }
2378  }
2379  else
2380  {
2381  // no override on or no previous entry, therefore consider incoming mode.
2382  bool new_value = ds_mitr->second & StateAttribute::ON;
2383  if (applyModeOnTexUnit(unit,ds_mitr->first,new_value,ms))
2384  {
2385  ms.changed = true;
2386  }
2387  }
2388 
2389  ++this_mitr;
2390  ++ds_mitr;
2391  }
2392  }
2393 
2394  // iterator over the remaining state modes to apply any previous changes.
2395  for(;
2396  this_mitr!=modeMap.end();
2397  ++this_mitr)
2398  {
2399  // note GLMode = this_mitr->first
2400  ModeStack& ms = this_mitr->second;
2401  if (ms.changed)
2402  {
2403  ms.changed = false;
2404  if (!ms.valueVec.empty())
2405  {
2406  bool new_value = ms.valueVec.back() & StateAttribute::ON;
2407  applyModeOnTexUnit(unit,this_mitr->first,new_value,ms);
2408  }
2409  else
2410  {
2411  // assume default of disabled.
2412  applyModeOnTexUnit(unit,this_mitr->first,ms.global_default_value,ms);
2413 
2414  }
2415 
2416  }
2417  }
2418 
2419  // iterator over the remaining incoming modes to apply any new mode.
2420  for(;
2421  ds_mitr!=modeList.end();
2422  ++ds_mitr)
2423  {
2424  ModeStack& ms = modeMap[ds_mitr->first];
2425 
2426  bool new_value = ds_mitr->second & StateAttribute::ON;
2427  applyModeOnTexUnit(unit,ds_mitr->first,new_value,ms);
2428 
2429  // will need to disable this mode on next apply so set it to changed.
2430  ms.changed = true;
2431  }
2432 }
2433 
2434 inline void State::applyAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
2435 {
2436  StateSet::AttributeList::const_iterator ds_aitr=attributeList.begin();
2437 
2438  AttributeMap::iterator this_aitr=attributeMap.begin();
2439 
2440  while (this_aitr!=attributeMap.end() && ds_aitr!=attributeList.end())
2441  {
2442  if (this_aitr->first<ds_aitr->first)
2443  {
2444 
2445  // note attribute type = this_aitr->first
2446  AttributeStack& as = this_aitr->second;
2447  if (as.changed)
2448  {
2449  as.changed = false;
2450  if (!as.attributeVec.empty())
2451  {
2452  const StateAttribute* new_attr = as.attributeVec.back().first;
2453  applyAttribute(new_attr,as);
2454  }
2455  else
2456  {
2458  }
2459  }
2460 
2461  ++this_aitr;
2462 
2463  }
2464  else if (ds_aitr->first<this_aitr->first)
2465  {
2466 
2467  // ds_aitr->first is a new attribute, therefore
2468  // need to insert a new attribute entry for ds_aitr->first.
2469  AttributeStack& as = attributeMap[ds_aitr->first];
2470 
2471  const StateAttribute* new_attr = ds_aitr->second.first.get();
2472  applyAttribute(new_attr,as);
2473 
2474  as.changed = true;
2475 
2476  ++ds_aitr;
2477 
2478  }
2479  else
2480  {
2481  // this_mitr & ds_mitr refer to the same attribute, check the override
2482  // if any otherwise just apply the incoming attribute
2483 
2484  AttributeStack& as = this_aitr->second;
2485 
2486  if (!as.attributeVec.empty() && (as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(ds_aitr->second.second & StateAttribute::PROTECTED))
2487  {
2488  // override is on, just treat as a normal apply on attribute.
2489 
2490  if (as.changed)
2491  {
2492  as.changed = false;
2493  const StateAttribute* new_attr = as.attributeVec.back().first;
2494  applyAttribute(new_attr,as);
2495  }
2496  }
2497  else
2498  {
2499  // no override on or no previous entry, therefore consider incoming attribute.
2500  const StateAttribute* new_attr = ds_aitr->second.first.get();
2501  if (applyAttribute(new_attr,as))
2502  {
2503  as.changed = true;
2504  }
2505  }
2506 
2507  ++this_aitr;
2508  ++ds_aitr;
2509  }
2510  }
2511 
2512  // iterator over the remaining state attributes to apply any previous changes.
2513  for(;
2514  this_aitr!=attributeMap.end();
2515  ++this_aitr)
2516  {
2517  // note attribute type = this_aitr->first
2518  AttributeStack& as = this_aitr->second;
2519  if (as.changed)
2520  {
2521  as.changed = false;
2522  if (!as.attributeVec.empty())
2523  {
2524  const StateAttribute* new_attr = as.attributeVec.back().first;
2525  applyAttribute(new_attr,as);
2526  }
2527  else
2528  {
2530  }
2531  }
2532  }
2533 
2534  // iterator over the remaining incoming attribute to apply any new attribute.
2535  for(;
2536  ds_aitr!=attributeList.end();
2537  ++ds_aitr)
2538  {
2539  // ds_aitr->first is a new attribute, therefore
2540  // need to insert a new attribute entry for ds_aitr->first.
2541  AttributeStack& as = attributeMap[ds_aitr->first];
2542 
2543  const StateAttribute* new_attr = ds_aitr->second.first.get();
2544  applyAttribute(new_attr,as);
2545 
2546  // will need to update this attribute on next apply so set it to changed.
2547  as.changed = true;
2548  }
2549 
2550 }
2551 
2552 inline void State::applyAttributeListOnTexUnit(unsigned int unit,AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
2553 {
2554  StateSet::AttributeList::const_iterator ds_aitr=attributeList.begin();
2555 
2556  AttributeMap::iterator this_aitr=attributeMap.begin();
2557 
2558  while (this_aitr!=attributeMap.end() && ds_aitr!=attributeList.end())
2559  {
2560  if (this_aitr->first<ds_aitr->first)
2561  {
2562 
2563  // note attribute type = this_aitr->first
2564  AttributeStack& as = this_aitr->second;
2565  if (as.changed)
2566  {
2567  as.changed = false;
2568  if (!as.attributeVec.empty())
2569  {
2570  const StateAttribute* new_attr = as.attributeVec.back().first;
2571  applyAttributeOnTexUnit(unit,new_attr,as);
2572  }
2573  else
2574  {
2576  }
2577  }
2578 
2579  ++this_aitr;
2580 
2581  }
2582  else if (ds_aitr->first<this_aitr->first)
2583  {
2584 
2585  // ds_aitr->first is a new attribute, therefore
2586  // need to insert a new attribute entry for ds_aitr->first.
2587  AttributeStack& as = attributeMap[ds_aitr->first];
2588 
2589  const StateAttribute* new_attr = ds_aitr->second.first.get();
2590  applyAttributeOnTexUnit(unit,new_attr,as);
2591 
2592  as.changed = true;
2593 
2594  ++ds_aitr;
2595 
2596  }
2597  else
2598  {
2599  // this_mitr & ds_mitr refer to the same attribute, check the override
2600  // if any otherwise just apply the incoming attribute
2601 
2602  AttributeStack& as = this_aitr->second;
2603 
2604  if (!as.attributeVec.empty() && (as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(ds_aitr->second.second & StateAttribute::PROTECTED))
2605  {
2606  // override is on, just treat as a normal apply on attribute.
2607 
2608  if (as.changed)
2609  {
2610  as.changed = false;
2611  const StateAttribute* new_attr = as.attributeVec.back().first;
2612  applyAttributeOnTexUnit(unit,new_attr,as);
2613  }
2614  }
2615  else
2616  {
2617  // no override on or no previous entry, therefore consider incoming attribute.
2618  const StateAttribute* new_attr = ds_aitr->second.first.get();
2619  if (applyAttributeOnTexUnit(unit,new_attr,as))
2620  {
2621  as.changed = true;
2622  }
2623  }
2624 
2625  ++this_aitr;
2626  ++ds_aitr;
2627  }
2628  }
2629 
2630  // iterator over the remaining state attributes to apply any previous changes.
2631  for(;
2632  this_aitr!=attributeMap.end();
2633  ++this_aitr)
2634  {
2635  // note attribute type = this_aitr->first
2636  AttributeStack& as = this_aitr->second;
2637  if (as.changed)
2638  {
2639  as.changed = false;
2640  if (!as.attributeVec.empty())
2641  {
2642  const StateAttribute* new_attr = as.attributeVec.back().first;
2643  applyAttributeOnTexUnit(unit,new_attr,as);
2644  }
2645  else
2646  {
2648  }
2649  }
2650  }
2651 
2652  // iterator over the remaining incoming attribute to apply any new attribute.
2653  for(;
2654  ds_aitr!=attributeList.end();
2655  ++ds_aitr)
2656  {
2657  // ds_aitr->first is a new attribute, therefore
2658  // need to insert a new attribute entry for ds_aitr->first.
2659  AttributeStack& as = attributeMap[ds_aitr->first];
2660 
2661  const StateAttribute* new_attr = ds_aitr->second.first.get();
2662  applyAttributeOnTexUnit(unit,new_attr,as);
2663 
2664  // will need to update this attribute on next apply so set it to changed.
2665  as.changed = true;
2666  }
2667 
2668 }
2669 
2670 inline void State::applyUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList)
2671 {
2672  if (!_lastAppliedProgramObject) return;
2673 
2674  StateSet::UniformList::const_iterator ds_aitr=uniformList.begin();
2675 
2676  UniformMap::iterator this_aitr=uniformMap.begin();
2677 
2678  while (this_aitr!=uniformMap.end() && ds_aitr!=uniformList.end())
2679  {
2680  if (this_aitr->first<ds_aitr->first)
2681  {
2682  // note attribute type = this_aitr->first
2683  UniformStack& as = this_aitr->second;
2684  if (!as.uniformVec.empty())
2685  {
2686  _lastAppliedProgramObject->apply(*as.uniformVec.back().first);
2687  }
2688 
2689  ++this_aitr;
2690 
2691  }
2692  else if (ds_aitr->first<this_aitr->first)
2693  {
2694  _lastAppliedProgramObject->apply(*(ds_aitr->second.first.get()));
2695 
2696  ++ds_aitr;
2697  }
2698  else
2699  {
2700  // this_mitr & ds_mitr refer to the same attribute, check the override
2701  // if any otherwise just apply the incoming attribute
2702 
2703  UniformStack& as = this_aitr->second;
2704 
2705  if (!as.uniformVec.empty() && (as.uniformVec.back().second & StateAttribute::OVERRIDE) && !(ds_aitr->second.second & StateAttribute::PROTECTED))
2706  {
2707  // override is on, just treat as a normal apply on uniform.
2708  _lastAppliedProgramObject->apply(*as.uniformVec.back().first);
2709  }
2710  else
2711  {
2712  // no override on or no previous entry, therefore consider incoming attribute.
2713  _lastAppliedProgramObject->apply(*(ds_aitr->second.first.get()));
2714  }
2715 
2716  ++this_aitr;
2717  ++ds_aitr;
2718  }
2719  }
2720 
2721  // iterator over the remaining state attributes to apply any previous changes.
2722  for(;
2723  this_aitr!=uniformMap.end();
2724  ++this_aitr)
2725  {
2726  // note attribute type = this_aitr->first
2727  UniformStack& as = this_aitr->second;
2728  if (!as.uniformVec.empty())
2729  {
2730  _lastAppliedProgramObject->apply(*as.uniformVec.back().first);
2731  }
2732  }
2733 
2734  // iterator over the remaining incoming attribute to apply any new attribute.
2735  for(;
2736  ds_aitr!=uniformList.end();
2737  ++ds_aitr)
2738  {
2739  _lastAppliedProgramObject->apply(*(ds_aitr->second.first.get()));
2740  }
2741 
2742 }
2743 
2744 inline void State::applyDefineList(DefineMap& defineMap, const StateSet::DefineList& defineList)
2745 {
2746  StateSet::DefineList::const_iterator dl_itr = defineList.begin();
2747  DefineMap::DefineStackMap::iterator dm_itr = defineMap.map.begin();
2748 
2749  defineMap.changed = false;
2750  defineMap.currentDefines.clear();
2751 
2752  while (dm_itr!=defineMap.map.end() && dl_itr!=defineList.end())
2753  {
2754  if (dm_itr->first<dl_itr->first)
2755  {
2756  DefineStack& ds = dm_itr->second;
2758  if (!dv.empty() && (dv.back().second & StateAttribute::ON)!=0) defineMap.currentDefines[dm_itr->first] = dv.back();
2759 
2760  ++dm_itr;
2761  }
2762  else if (dl_itr->first<dm_itr->first)
2763  {
2764  if ((dl_itr->second.second & StateAttribute::ON)!=0) defineMap.currentDefines[dl_itr->first] = dl_itr->second;
2765 
2766  ++dl_itr;
2767  }
2768  else
2769  {
2770  // this_mitr & ds_mitr refer to the same mode, check the override
2771  // if any otherwise just apply the incoming mode.
2772 
2773  DefineStack& ds = dm_itr->second;
2775 
2776  if (!dv.empty() && (dv.back().second & StateAttribute::OVERRIDE)!=0 && !(dl_itr->second.second & StateAttribute::PROTECTED))
2777  {
2778  // override is on, just treat as a normal apply on modes.
2779  if ((dv.back().second & StateAttribute::ON)!=0) defineMap.currentDefines[dm_itr->first] = dv.back();
2780  }
2781  else
2782  {
2783  // no override on or no previous entry, therefore consider incoming mode.
2784  if ((dl_itr->second.second & StateAttribute::ON)!=0) defineMap.currentDefines[dl_itr->first] = dl_itr->second;
2785  }
2786 
2787  ++dm_itr;
2788  ++dl_itr;
2789  }
2790  }
2791 
2792  // iterator over the remaining state modes to apply any previous changes.
2793  for(;
2794  dm_itr!=defineMap.map.end();
2795  ++dm_itr)
2796  {
2797  // note GLMode = this_mitr->first
2798  DefineStack& ds = dm_itr->second;
2800  if (!dv.empty() && (dv.back().second & StateAttribute::ON)!=0) defineMap.currentDefines[dm_itr->first] = dv.back();
2801  }
2802 
2803  // iterator over the remaining incoming modes to apply any new mode.
2804  for(;
2805  dl_itr!=defineList.end();
2806  ++dl_itr)
2807  {
2808  if ((dl_itr->second.second & StateAttribute::ON)!=0) defineMap.currentDefines[dl_itr->first] = dl_itr->second;
2809  }
2810 }
2811 
2812 inline void State::applyModeMap(ModeMap& modeMap)
2813 {
2814  for(ModeMap::iterator mitr=modeMap.begin();
2815  mitr!=modeMap.end();
2816  ++mitr)
2817  {
2818  // note GLMode = mitr->first
2819  ModeStack& ms = mitr->second;
2820  if (ms.changed)
2821  {
2822  ms.changed = false;
2823  if (!ms.valueVec.empty())
2824  {
2825  bool new_value = ms.valueVec.back() & StateAttribute::ON;
2826  applyMode(mitr->first,new_value,ms);
2827  }
2828  else
2829  {
2830  // assume default of disabled.
2831  applyMode(mitr->first,ms.global_default_value,ms);
2832  }
2833 
2834  }
2835  }
2836 }
2837 
2838 inline void State::applyModeMapOnTexUnit(unsigned int unit,ModeMap& modeMap)
2839 {
2840  for(ModeMap::iterator mitr=modeMap.begin();
2841  mitr!=modeMap.end();
2842  ++mitr)
2843  {
2844  // note GLMode = mitr->first
2845  ModeStack& ms = mitr->second;
2846  if (ms.changed)
2847  {
2848  ms.changed = false;
2849  if (!ms.valueVec.empty())
2850  {
2851  bool new_value = ms.valueVec.back() & StateAttribute::ON;
2852  applyModeOnTexUnit(unit,mitr->first,new_value,ms);
2853  }
2854  else
2855  {
2856  // assume default of disabled.
2857  applyModeOnTexUnit(unit,mitr->first,ms.global_default_value,ms);
2858  }
2859 
2860  }
2861  }
2862 }
2863 
2864 inline void State::applyAttributeMap(AttributeMap& attributeMap)
2865 {
2866  for(AttributeMap::iterator aitr=attributeMap.begin();
2867  aitr!=attributeMap.end();
2868  ++aitr)
2869  {
2870  AttributeStack& as = aitr->second;
2871  if (as.changed)
2872  {
2873  as.changed = false;
2874  if (!as.attributeVec.empty())
2875  {
2876  const StateAttribute* new_attr = as.attributeVec.back().first;
2877  applyAttribute(new_attr,as);
2878  }
2879  else
2880  {
2882  }
2883 
2884  }
2885  }
2886 }
2887 
2888 inline void State::applyAttributeMapOnTexUnit(unsigned int unit,AttributeMap& attributeMap)
2889 {
2890  for(AttributeMap::iterator aitr=attributeMap.begin();
2891  aitr!=attributeMap.end();
2892  ++aitr)
2893  {
2894  AttributeStack& as = aitr->second;
2895  if (as.changed)
2896  {
2897  as.changed = false;
2898  if (!as.attributeVec.empty())
2899  {
2900  const StateAttribute* new_attr = as.attributeVec.back().first;
2901  applyAttributeOnTexUnit(unit,new_attr,as);
2902  }
2903  else
2904  {
2906  }
2907 
2908  }
2909  }
2910 }
2911 
2912 inline void State::applyUniformMap(UniformMap& uniformMap)
2913 {
2914  if (!_lastAppliedProgramObject) return;
2915 
2916  for(UniformMap::iterator aitr=uniformMap.begin();
2917  aitr!=uniformMap.end();
2918  ++aitr)
2919  {
2920  UniformStack& as = aitr->second;
2921  if (!as.uniformVec.empty())
2922  {
2923  _lastAppliedProgramObject->apply(*as.uniformVec.back().first);
2924  }
2925  }
2926 }
2927 
2928 inline bool State::setActiveTextureUnit( unsigned int unit )
2929 {
2930  if (unit!=_currentActiveTextureUnit)
2931  {
2932  if (_glActiveTexture && unit < (unsigned int)(maximum(_glMaxTextureCoords,_glMaxTextureUnits)) )
2933  {
2936  }
2937  else
2938  {
2939  return unit==0;
2940  }
2941  }
2942  return true;
2943 }
2944 
2945 // forward declare speciailization of State::get() method
2946 template<> inline GLExtensions* State::get<GLExtensions>() { return _glExtensions.get(); }
2947 template<> inline const GLExtensions* State::get<GLExtensions>() const { return _glExtensions.get(); }
2948 
2949 }
2950 
2951 #endif
void setGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode, bool enabled)
Definition: State.h:380
void applyUniformList(UniformMap &uniformMap, const StateSet::UniformList &uniformList)
Definition: State.h:2670
const VertexAttribAlias & getSecondaryColorAlias()
Definition: State.h:307
void setColorAlias(const VertexAttribAlias &alias)
Definition: State.h:302
void applyDefineList(DefineMap &uniformMap, const StateSet::DefineList &defineList)
Definition: State.h:2744
std::vector< StateAttribute::GLModeValue > ValueVec
Definition: State.h:1538
void disableColorPointer()
Definition: State.h:893
std::string _glName
Definition: State.h:94
#define OSG_EXPORT
Definition: Export.h:43
StateSetStack & getStateSetStack()
Definition: State.h:237
GLint getAttribLocation(const std::string &name) const
Definition: State.h:1377
GLfloat x
Definition: State.h:1950
SecondaryColorPointerProc _glSecondaryColorPointer
Definition: State.h:1972
void setTexCoordPointer(unsigned int unit, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE)
Definition: State.h:1091
virtual void apply(State &) const
void apply(const Uniform &uniform) const
Definition: Program.h:317
GLint getDataSize() const
Definition: Array.h:156
TypeMemberPair getTypeMemberPair() const
void setVertexAttribPointer(unsigned int unit, const Array *array)
Definition: State.h:1254
void applyAttributeMapOnTexUnit(unsigned int unit, AttributeMap &attributeMap)
Definition: State.h:2888
void disableNormalPointer()
Definition: State.h:801
GLfloat GLfloat GLfloat GLfloat w
Definition: State.h:1950
#define GL_PIXEL_UNPACK_BUFFER_ARB
Definition: BufferObject.h:84
AttributeMap _attributeMap
Definition: State.h:1841
void setTexCoordAliasList(const VertexAttribAliasList &aliasList)
Definition: State.h:314
VertexAttribPointerProc _glVertexAttribPointer
Definition: State.h:1973
void Color(float r, float g, float b, float a=1.0f)
Definition: State.h:596
void setGraphicsCostEstimator(GraphicsCostEstimator *gce)
Definition: State.h:1500
std::vector< const StateSet * > StateSetStack
Definition: State.h:234
StateSetStack _stateStateStack
Definition: State.h:1850
VertexAttrib4fvProc _glVertexAttrib4fv
Definition: State.h:1970
GLint _glMaxTextureCoords
Definition: State.h:1964
VertexAttribIPointerProc _glVertexAttribIPointer
Definition: State.h:1974
bool * _abortRenderingPtr
Definition: State.h:1672
void setNormalAlias(const VertexAttribAlias &alias)
Definition: State.h:298
virtual Object * cloneType() const =0
EnabledArrayPair(const EnabledArrayPair &eap)
Definition: State.h:1859
const VertexAttribAlias & getNormalAlias()
Definition: State.h:299
#define GL_FOG_COORDINATE_ARRAY
Definition: State.h:45
void setVertexAttribLPointer(unsigned int unit, const Array *array)
Definition: State.h:1273
bool getAbortRendering() const
Definition: State.h:1413
std::map< std::string, UniformStack > UniformMap
Definition: State.h:1624
bool global_default_value
Definition: State.h:1553
bool applyModeOnTexUnit(unsigned int unit, StateAttribute::GLMode mode, bool enabled, ModeStack &ms)
Definition: State.h:1713
void applyModeMapOnTexUnit(unsigned int unit, ModeMap &modeMap)
Definition: State.h:2838
const VertexAttribAlias & getFogCoordAlias()
Definition: State.h:311
VertexAttribAlias _colorAlias
Definition: State.h:1679
void TexCoord(float x, float y=0.0f, float z=0.0f, float w=1.0f)
Definition: State.h:616
void pushAttributeList(AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
Definition: State.h:2025
ref_ptr< FrameStamp > _frameStamp
Definition: State.h:1654
std::pair< const StateAttribute *, StateAttribute::OverrideValue > AttributePair
Definition: State.h:1379
void setVertexPointer(const Array *array)
Definition: State.h:658
unsigned int getMaxBufferObjectPoolSize() const
Definition: State.h:1458
const FrameStamp * getFrameStamp() const
Definition: State.h:1395
StateSet::DefineList currentDefines
Definition: State.h:1612
ref_ptr< Uniform > _modelViewMatrixUniform
Definition: State.h:1663
ref_ptr< DisplaySettings > _displaySettings
Definition: State.h:1670
void applyAttributeListOnTexUnit(unsigned int unit, AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
Definition: State.h:2552
FrameStamp * getFrameStamp()
Definition: State.h:1392
unsigned int _maxTexturePoolSize
Definition: State.h:1852
bool _useModelViewAndProjectionUniforms
Definition: State.h:1662
#define GL_TEXTURE0
StateSet::UniformList & getCurrentShaderCompositionUniformList()
Definition: State.h:201
bool getModeValidity(StateAttribute::GLMode mode)
Definition: State.h:346
Program::AttribBindingList _attributeBindingList
Definition: State.h:1684
bool _extensionProcsInitialized
Definition: State.h:1963
FogCoordPointerProc _glFogCoordPointer
Definition: State.h:1971
void setTexCoordPointer(unsigned int unit, const Array *array)
Definition: State.h:1071
void setCurrentPixelBufferObject(osg::GLBufferObject *pbo)
Definition: State.h:544
const AttributeMap & getAttributeMap() const
Definition: State.h:1630
AttributeMap & getOrCreateTextureAttributeMap(unsigned int unit)
Definition: State.h:1894
void unbindPixelBufferObject()
Definition: State.h:557
CheckForGLErrors getCheckForGLErrors() const
Definition: State.h:1480
void setLastAppliedProgramObject(const Program::PerContextProgram *program)
Definition: State.h:1358
UniformVec uniformVec
Definition: State.h:1588
void setCheckForGLErrors(CheckForGLErrors check)
Definition: State.h:1477
void setFogCoordPointer(const Array *array)
Definition: State.h:1004
VertexAttribAlias _normalAlias
Definition: State.h:1678
ArrayDispatchers & getArrayDispatchers()
Definition: State.h:1496
double delta_s(Timer_t t1, Timer_t t2) const
Definition: Timer.h:59
void setGlobalDefaultAttribute(const StateAttribute *attribute)
Definition: State.h:402
const StateAttribute * last_applied_attribute
Definition: State.h:1572
GLint getUniformLocation(const std::string &uniformName) const
Definition: State.h:1376
void applyAttributeMap(AttributeMap &attributeMap)
Definition: State.h:2864
void setDisplaySettings(DisplaySettings *vs)
Definition: State.h:1401
GLboolean GLsizei stride
Definition: State.h:1953
bool getGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode)
Definition: State.h:387
GraphicsContext * _graphicsContext
Definition: State.h:1645
bool _isVertexBufferObjectSupported
Definition: State.h:1944
void dirtyTexCoordPointersAboveAndIncluding(unsigned int unit)
Definition: State.h:1207
void dirtySecondaryColorPointer()
Definition: State.h:983
ref_ptr< Uniform > _projectionMatrixUniform
Definition: State.h:1664
void dirtyVertexAttribPointersAboveAndIncluding(unsigned int index)
Definition: State.h:1344
bool getUseModelViewAndProjectionUniforms() const
Definition: State.h:270
EnabledVertexAttribArrayList _vertexAttribArrayList
Definition: State.h:1878
std::vector< UniformPair > UniformVec
Definition: State.h:1582
bool _isSecondaryColorSupportResolved
Definition: State.h:1935
VertexAttribLPointerProc _glVertexAttribLPointer
Definition: State.h:1975
unsigned int _currentActiveTextureUnit
Definition: State.h:1880
osg::ref_ptr< DynamicObjectRenderingCompletedCallback > _completeDynamicObjectRenderingCallback
Definition: State.h:1985
DefineMap & getDefineMap()
Definition: State.h:1632
const TextureModeMapList & getTextureModeMapList() const
Definition: State.h:1634
std::set< std::string > ShaderDefines
Definition: Shader.h:34
ref_ptr< const RefMatrix > _identity
Definition: State.h:1656
std::pair< ref_ptr< Uniform >, StateAttribute::OverrideValue > RefUniformPair
Definition: StateSet.h:273
std::map< std::string, DefinePair > DefineList
Definition: StateSet.h:313
Timer_t getGpuTick() const
Definition: State.h:1516
ref_ptr< const RefMatrix > _modelView
Definition: State.h:1659
bool applyGlobalDefaultAttributeOnTexUnit(unsigned int unit, AttributeStack &as)
Definition: State.h:1813
void glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
Definition: State.h:573
const osg::Matrix & getProjectionMatrix() const
Definition: State.h:262
void Vertex(float x, float y, float z, float w=1.0f)
Definition: State.h:586
std::map< StateAttribute::GLMode, StateAttribute::GLModeValue > ModeList
Definition: StateSet.h:111
EnabledArrayPair _secondaryColorArray
Definition: State.h:1875
ShaderComposer * getShaderComposer()
Definition: State.h:195
const Program::PerContextProgram * getLastAppliedProgramObject() const
Definition: State.h:1365
bool _shaderCompositionEnabled
Definition: State.h:1648
void setShaderComposer(ShaderComposer *sc)
Definition: State.h:192
osg::Uniform * getProjectionMatrixUniform()
Definition: State.h:277
bool applyMode(StateAttribute::GLMode mode, bool enabled, ModeStack &ms)
Definition: State.h:1696
VertexAttribAlias(const VertexAttribAlias &rhs)
Definition: State.h:81
const osg::Matrix & getModelViewMatrix() const
Definition: State.h:267
std::vector< AttributePair > AttributeVec
Definition: State.h:1380
void applyAttributeList(AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
Definition: State.h:2434
GLuint64 _gpuTimestamp
Definition: State.h:1994
std::vector< StateSet::DefinePair > DefineVec
Definition: State.h:1593
const osg::Matrix & getInitialViewMatrix() const
Definition: State.h:257
ShaderComponent * getShaderComponent()
osg::Program * _currentShaderCompositionProgram
Definition: State.h:1651
ref_ptr< const RefMatrix > _projection
Definition: State.h:1658
bool applyMode(StateAttribute::GLMode mode, bool enabled)
Definition: State.h:373
unsigned long long Timer_t
Definition: Timer.h:24
void VerteAttrib(unsigned int location, float x, float y=0.0f, float z=0.0f, float w=0.0f)
Definition: State.h:640
StateSet::UniformList _currentShaderCompositionUniformList
Definition: State.h:1652
const UniformMap & getUniformMap() const
Definition: State.h:1631
void setTimestampBits(int bits)
Definition: State.h:1530
VertexAttrib4fProc _glVertexAttrib4f
Definition: State.h:1969
GraphicsCostEstimator * getGraphicsCostEstimator()
Definition: State.h:1503
const Program::AttribBindingList & getAttributeBindingList()
Definition: State.h:319
EnableVertexAttribProc _glEnableVertexAttribArray
Definition: State.h:1976
const VertexAttribAlias & getVertexAlias()
Definition: State.h:295
UniformMap _uniformMap
Definition: State.h:1842
void setColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_TRUE)
Definition: State.h:862
TextureAttributeMapList _textureAttributeMapList
Definition: State.h:1846
unsigned int OverrideValue
void popAttributeList(AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
Definition: State.h:2137
osg::ref_ptr< ShaderComposer > _shaderComposer
Definition: State.h:1650
static Timer * instance()
std::vector< AttributeMap > TextureAttributeMapList
Definition: State.h:1622
DrawElementsInstancedProc _glDrawElementsInstanced
Definition: State.h:1980
std::map< StateAttribute::TypeMemberPair, RefAttributePair > AttributeList
Definition: StateSet.h:158
void popStateSetStackToSize(unsigned int size)
Definition: State.h:232
T maximum(T lhs, T rhs)
Definition: Math.h:66
void dirtyNormalPointer()
Definition: State.h:823
DefineMap _defineMap
Definition: State.h:1843
int getTimestampBits() const
Definition: State.h:1529
DefineVec defineVec
Definition: State.h:1601
unsigned int getDynamicObjectCount() const
Definition: State.h:1441
VertexAttribAlias _vertexAlias
Definition: State.h:1677
void setVertexAlias(const VertexAttribAlias &alias)
Definition: State.h:294
const TextureAttributeMapList & getTextureAttributeMapList() const
Definition: State.h:1635
unsigned int getActiveTextureUnit() const
Definition: State.h:1243
#define GL_ARRAY_BUFFER_ARB
Definition: BufferObject.h:29
GLint _glMaxTextureUnits
Definition: State.h:1965
AttributeVec & getAttributeVec(const osg::StateAttribute *attribute)
Definition: State.h:1382
void applyShaderCompositionUniform(const osg::Uniform *uniform, StateAttribute::OverrideValue value=StateAttribute::ON)
Definition: State.h:204
std::string _declaration
Definition: State.h:96
void setGraphicsContext(GraphicsContext *context)
Definition: State.h:124
bool applyAttributeOnTexUnit(unsigned int unit, const StateAttribute *attribute, AttributeStack &as)
Definition: State.h:1760
const GraphicsContext * getGraphicsContext() const
Definition: State.h:130
bool _isSecondaryColorSupported
Definition: State.h:1936
void pushUniformList(UniformMap &uniformMap, const StateSet::UniformList &uniformList)
Definition: State.h:2055
bool isVertexBufferObjectSupported() const
Definition: State.h:1355
TextureModeMapList _textureModeMapList
Definition: State.h:1845
const DisplaySettings * getDisplaySettings() const
Definition: State.h:1404
std::vector< GLuint > IndicesGLuint
Definition: State.h:568
void setSecondaryColorPointer(const Array *array)
Definition: State.h:937
const StateAttribute * getGlobalDefaultAttribute(StateAttribute::Type type, unsigned int member=0)
Definition: State.h:408
typedef void(GL_APIENTRY *GLTexImage3DProc)(GLenum target
#define GL_ELEMENT_ARRAY_BUFFER_ARB
Definition: BufferObject.h:30
GLBufferObject * _currentPBO
Definition: State.h:1884
GLsizeiptr getOffset(unsigned int i) const
Definition: BufferObject.h:201
ModeMap _modeMap
Definition: State.h:1840
unsigned int getBufferIndex() const
Definition: BufferObject.h:540
std::vector< EnabledArrayPair > EnabledTexCoordArrayList
Definition: State.h:1869
const std::string & getName() const
Definition: Object.h:144
osg::Uniform * getModelViewMatrixUniform()
Definition: State.h:276
bool isSecondaryColorSupported() const
Definition: State.h:933
GraphicsContext * getGraphicsContext()
Definition: State.h:127
const DefineMap & getDefineMap() const
Definition: State.h:1633
unsigned int GLModeValue
GLint getMaxTextureUnits() const
For GL>=2.0 uses GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, for GL<2 uses GL_MAX_TEXTURE_UNITS.
Definition: State.h:1234
const GLvoid * _pointer
Definition: State.h:1866
void setFrameStamp(FrameStamp *fs)
Definition: State.h:1389
const osg::Matrix & getInitialInverseViewMatrix() const
Definition: State.h:258
void applyUniformMap(UniformMap &uniformMap)
Definition: State.h:2912
DynamicObjectRenderingCompletedCallback * getDynamicObjectRenderingCompletedCallback()
Definition: State.h:1425
const GLBufferObject * getCurrentElementBufferObject()
Definition: State.h:527
DefineStackMap map
Definition: State.h:1610
const ShaderComposer * getShaderComposer() const
Definition: State.h:198
ActiveTextureProc _glClientActiveTexture
Definition: State.h:1966
bool applyTextureAttribute(unsigned int unit, const StateAttribute *attribute)
Definition: State.h:437
void dirtyColorPointer()
Definition: State.h:915
bool applyTextureMode(unsigned int unit, StateAttribute::GLMode mode, bool enabled)
Definition: State.h:394
void disableTexCoordPointersAboveAndIncluding(unsigned int unit)
Definition: State.h:1177
const VertexAttribAlias & getColorAlias()
Definition: State.h:303
EnabledArrayPair _fogArray
Definition: State.h:1876
GLint getMaxTextureCoords() const
For GL>=2.0 uses GL_MAX_TEXTURE_COORDS, for GL<2 uses GL_MAX_TEXTURE_UNITS.
Definition: State.h:1231
void setColorPointer(const Array *array)
Definition: State.h:841
GLboolean normalized
Definition: State.h:1953
Timer_t _startTick
Definition: State.h:1992
double getGpuTime() const
Definition: State.h:1518
T * get() const
Definition: ref_ptr.h:92
void dirtyTexCoordPointer(unsigned int unit)
Definition: State.h:1157
unsigned int getContextID() const
Definition: State.h:151
void applyModeListOnTexUnit(unsigned int unit, ModeMap &modeMap, const StateSet::ModeList &modeList)
Definition: State.h:2312
osg::Uniform * getNormalMatrixUniform()
Definition: State.h:279
const VertexAttribAliasList & getTexCoordAliasList()
Definition: State.h:315
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: GLU.h:71
std::map< std::string, DefineStack > DefineStackMap
Definition: State.h:1609
GLenum getDataType() const
Definition: Array.h:157
const Viewport * getCurrentViewport() const
Definition: State.h:249
void setCurrentElementBufferObject(osg::GLBufferObject *ebo)
Definition: State.h:526
bool _shaderCompositionDirty
Definition: State.h:1649
bool _isVertexBufferObjectSupportResolved
Definition: State.h:1943
AttributeVec attributeVec
Definition: State.h:1575
GLBufferObject * getOrCreateGLBufferObject(unsigned int contextID) const
Definition: BufferObject.h:543
void setUseModelViewAndProjectionUniforms(bool flag)
Definition: State.h:269
bool get(float &f) const
GLint getUniformLocation(unsigned int uniformNameID) const
Definition: State.h:1367
ExtensionMap _extensionMap
Definition: State.h:156
#define GL_APIENTRY
Definition: GL.h:118
void setFogCoordAlias(const VertexAttribAlias &alias)
Definition: State.h:310
CheckForGLErrors
Definition: State.h:1461
std::vector< EnabledArrayPair > EnabledVertexAttribArrayList
Definition: State.h:1870
void setCurrentVertexBufferObject(osg::GLBufferObject *vbo)
Definition: State.h:509
GLenum type
Definition: State.h:1949
void setVertexAttribIPointer(unsigned int unit, const Array *array)
Definition: State.h:1292
GLBufferObject * _currentEBO
Definition: State.h:1883
std::vector< VertexAttribAlias > VertexAttribAliasList
Definition: State.h:288
GLuint64 getGpuTimestamp() const
Definition: State.h:1522
std::vector< GLushort > IndicesGLushort
Definition: State.h:565
void MultiTexCoord(unsigned int unit, float x, float y=0.0f, float z=0.0f, float w=1.0f)
Definition: State.h:628
void setUseVertexAttributeAliasing(bool flag)
Definition: State.h:285
osg::ref_ptr< GraphicsCostEstimator > _graphicsCostEstimator
Definition: State.h:1990
EnabledArrayPair _normalArray
Definition: State.h:1873
void pushDefineList(DefineMap &defineMap, const StateSet::DefineList &defineList)
Definition: State.h:2083
std::map< std::string, GLuint > AttribBindingList
Definition: Program.h:217
void disableSecondaryColorPointer()
Definition: State.h:961
ref_ptr< const RefMatrix > _initialViewMatrix
Definition: State.h:1657
bool getGlobalDefaultModeValue(StateAttribute::GLMode mode)
Definition: State.h:358
unsigned int _currentClientActiveTextureUnit
Definition: State.h:1881
const Program::PerContextProgram * _lastAppliedProgramObject
Definition: State.h:1848
void bindElementBufferObject(osg::GLBufferObject *ebo)
Definition: State.h:529
GLBeginEndAdapter & getGLBeginEndAdapter()
Definition: State.h:1493
bool applyAttribute(const StateAttribute *attribute)
Definition: State.h:415
VertexAttribAlias _secondaryColorAlias
Definition: State.h:1680
std::map< StateAttribute::GLMode, ModeStack > ModeMap
Definition: State.h:1618
ref_ptr< Uniform > _modelViewProjectionMatrixUniform
Definition: State.h:1665
bool _isFogCoordSupportResolved
Definition: State.h:1939
unsigned int _contextID
Definition: State.h:1646
osg::ref_ptr< GLExtensions > _glExtensions
Definition: State.h:1982
const GLBufferObject * getCurrentVertexBufferObject()
Definition: State.h:510
void setGlobalDefaultModeValue(StateAttribute::GLMode mode, bool enabled)
Definition: State.h:352
const ShaderComponent * last_applied_shadercomponent
Definition: State.h:1573
DrawArraysInstancedProc _glDrawArraysInstanced
Definition: State.h:1979
void unbindVertexBufferObject()
Definition: State.h:519
Timer_t _gpuTick
Definition: State.h:1993
void dirtyVertexPointer()
Definition: State.h:731
void setAbortRenderingPtr(bool *abortPtr)
Definition: State.h:1409
void disableTexCoordPointer(unsigned int unit)
Definition: State.h:1129
Definition: AlphaFunc.h:19
std::map< std::string, RefUniformPair > UniformList
Definition: StateSet.h:276
GLfloat GLfloat GLfloat z
Definition: State.h:1950
void setAttributeBindingList(const Program::AttribBindingList &attribBindingList)
Definition: State.h:318
bool _useVertexAttributeAliasing
Definition: State.h:1676
void applyModeList(ModeMap &modeMap, const StateSet::ModeList &modeList)
Definition: State.h:2190
void setShaderCompositionEnabled(bool flag)
Definition: State.h:186
ModeMap & getOrCreateTextureModeMap(unsigned int unit)
Definition: State.h:1887
EnabledTexCoordArrayList _texCoordArrayList
Definition: State.h:1877
ref_ptr< const StateAttribute > global_default_attribute
Definition: State.h:1574
unsigned int _dynamicObjectCount
Definition: State.h:1984
void disableVertexPointer()
Definition: State.h:709
bool isFogCoordSupported() const
Definition: State.h:1000
GLBeginEndAdapter _glBeginEndAdapter
Definition: State.h:1987
void setGlobalDefaultTextureAttribute(unsigned int unit, const StateAttribute *attribute)
Definition: State.h:422
void setContextID(unsigned int contextID)
Definition: State.h:148
unsigned int getStateSetStackSize()
Definition: State.h:229
void popModeList(ModeMap &modeMap, const StateSet::ModeList &modeList)
Definition: State.h:2121
CheckForGLErrors _checkGLErrors
Definition: State.h:1673
void setNormalPointer(const Array *array)
Definition: State.h:750
GLfloat GLfloat y
Definition: State.h:1950
std::pair< std::string, StateAttribute::OverrideValue > DefinePair
Definition: StateSet.h:312
bool setActiveTextureUnit(unsigned int unit)
Definition: State.h:2928
void setDynamicObjectRenderingCompletedCallback(DynamicObjectRenderingCompletedCallback *cb)
Definition: State.h:1422
void unbindElementBufferObject()
Definition: State.h:537
bool _isFogCoordSupported
Definition: State.h:1940
GLsizei stride
Definition: State.h:1948
bool isDirty() const
Definition: BufferObject.h:210
void dirtyFogCoordPointer()
Definition: State.h:1051
bool applyGlobalDefaultAttribute(AttributeStack &as)
Definition: State.h:1790
bool getShaderCompositionEnabled() const
Definition: State.h:189
void setDynamicObjectCount(unsigned int count, bool callCallbackOnZero=false)
Definition: State.h:1428
void setNormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE)
Definition: State.h:770
std::map< const std::type_info *, osg::ref_ptr< osg::Referenced > > ExtensionMap
Definition: State.h:155
ref_ptr< Uniform > _normalMatrixUniform
Definition: State.h:1666
void decrementDynamicObjectCount()
Definition: State.h:1445
GLBufferObject * _currentVBO
Definition: State.h:1882
bool getUseVertexAttributeAliasing() const
Definition: State.h:286
DisableVertexAttribProc _glDisableVertexAttribArray
Definition: State.h:1977
BindBufferProc _glBindBuffer
Definition: State.h:1978
std::string _osgName
Definition: State.h:95
std::map< StateAttribute::TypeMemberPair, AttributeStack > AttributeMap
Definition: State.h:1621
void setSecondaryColorAlias(const VertexAttribAlias &alias)
Definition: State.h:306
bool applyAttribute(const StateAttribute *attribute, AttributeStack &as)
Definition: State.h:1736
ValueVec valueVec
Definition: State.h:1554
void popDefineList(DefineMap &uniformMap, const StateSet::DefineList &defineList)
Definition: State.h:2168
std::vector< ref_ptr< const Matrix > > MatrixStack
Definition: State.h:1627
const GLBufferObject * getCurrentPixelBufferObject()
Definition: State.h:545
void pushModeList(ModeMap &modeMap, const StateSet::ModeList &modeList)
Definition: State.h:1998
EnabledArrayPair _colorArray
Definition: State.h:1874
unsigned int _maxBufferObjectPoolSize
Definition: State.h:1853
void bindPixelBufferObject(osg::GLBufferObject *pbo)
Definition: State.h:547
void Normal(float x, float y, float z)
Definition: State.h:606
GLuint buffer
Definition: State.h:1958
osg::Uniform * getModelViewProjectionMatrixUniform()
Definition: State.h:278
void bindVertexBufferObject(osg::GLBufferObject *vbo)
Definition: State.h:511
ArrayDispatchers _arrayDispatchers
Definition: State.h:1988
virtual const GLvoid * getDataPointer() const =0
const StateAttribute * getGlobalDefaultTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0)
Definition: State.h:429
VertexAttribAlias(GLuint location, const std::string glName, const std::string osgName, const std::string &declaration)
Definition: State.h:87
void applyModeMap(ModeMap &modeMap)
Definition: State.h:2812
const GraphicsCostEstimator * getGraphicsCostEstimator() const
Definition: State.h:1506
std::pair< const Uniform *, StateAttribute::OverrideValue > UniformPair
Definition: State.h:1581
VertexAttribAliasList _texCoordAliasList
Definition: State.h:1682
void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
Definition: State.h:579
void setGpuTimestamp(Timer_t tick, GLuint64 timestamp)
Definition: State.h:1524
ActiveTextureProc _glActiveTexture
Definition: State.h:1967
GLsizei const GLvoid * pointer
Definition: State.h:1948
const ModeMap & getModeMap() const
Definition: State.h:1629
void popUniformList(UniformMap &uniformMap, const StateSet::UniformList &uniformList)
Definition: State.h:2153
VertexAttribAlias _fogCoordAlias
Definition: State.h:1681
unsigned int getMaxTexturePoolSize() const
Definition: State.h:1455
Matrix _initialInverseViewMatrix
Definition: State.h:1668
EnabledArrayPair _vertexArray
Definition: State.h:1872
void setVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE)
Definition: State.h:678
void setModeValidity(StateAttribute::GLMode mode, bool valid)
Definition: State.h:338
Timer_t getStartTick() const
Definition: State.h:1514
std::pair< Type, unsigned int > TypeMemberPair
unsigned int getClientActiveTextureUnit() const
Definition: State.h:1251
void disableFogCoordPointer()
Definition: State.h:1029
bool getNormalize() const
Definition: Array.h:181
int _timestampBits
Definition: State.h:1995
MultiTexCoord4fProc _glMultiTexCoord4f
Definition: State.h:1968
void dirtyVertexAttribPointer(unsigned int index)
Definition: State.h:1334
void setStartTick(Timer_t tick)
Definition: State.h:1515
#define GL_SECONDARY_COLOR_ARRAY
Definition: State.h:53
ref_ptr< RefMatrix > _modelViewCache
Definition: State.h:1660
std::vector< ModeMap > TextureModeMapList
Definition: State.h:1619
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition: GLU.h:71