OpenSceneGraph 3.6.5
State
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#include <osg/VertexArrayState>
26
27#include <osg/ShaderComposer>
28#include <osg/FrameStamp>
29#include <osg/DisplaySettings>
30#include <osg/Polytope>
31#include <osg/Viewport>
34
35#include <iosfwd>
36#include <vector>
37#include <map>
38#include <set>
39#include <string>
40
41#ifndef GL_TEXTURE0
42#define GL_TEXTURE0 0x84C0
43#endif
44
45namespace osg {
46
49#define OSG_GL_DEBUG(message) \
50 if (state.getFineGrainedErrorDetection()) \
51 { \
52 GLenum errorNo = glGetError(); \
53 if (errorNo!=GL_NO_ERROR) \
54 { \
55 osg::notify(WARN)<<"Warning: detected OpenGL error '"<<gluErrorString(errorNo)<<" "<<message<<endl; \
56 }\
57 }
58
59
60// forward declare GraphicsContext, View and State
61class GraphicsContext;
62
80{
81 public :
82
84
85
88
91
94
95
111 inline void setContextID(unsigned int contextID) { _contextID=contextID; }
112
114 inline unsigned int getContextID() const { return _contextID; }
115
116
117 // ExtensionMap contains GL Extentsions objects used by StateAttribue to call OpenGL extensions/advanced features
118 typedef std::map<const std::type_info*, osg::ref_ptr<osg::Referenced> > ExtensionMap;
120
123 template<typename T>
124 T* get()
125 {
126 const std::type_info* id(&typeid(T));
128 if (!ptr)
129 {
130 ptr = new T(_contextID);
131 }
132 return static_cast<T*>(ptr.get());
133 }
134
138 template<typename T>
139 const T* get() const
140 {
141 const std::type_info* id(&typeid(T));
142 ExtensionMap::const_iterator itr = _extensionMap.find(id);
143 if (itr==_extensionMap.end()) return 0;
144 else return itr->second.get();
145 }
146
148 template<typename T>
149 void set(T* ptr)
150 {
151 const std::type_info* id(&typeid(T));
152 _extensionMap[id] = ptr;
153 }
154
155 /* deprecated.*/
157
158 /* deprecated.*/
160
163
166
168 const ShaderComposer* getShaderComposer() const { return _shaderComposer.get(); }
169
172
175 {
177 up.first = const_cast<Uniform*>(uniform);
178 up.second = value;
179 }
180
181
183 void pushStateSet(const StateSet* dstate);
184
187
191
193 void insertStateSet(unsigned int pos,const StateSet* dstate);
194
196 void removeStateSet(unsigned int pos);
197
199 unsigned int getStateSetStackSize() { return static_cast<unsigned int>(_stateStateStack.size()); }
200
202 void popStateSetStackToSize(unsigned int size) { while (_stateStateStack.size()>size) popStateSet(); }
203
204 typedef std::vector<const StateSet*> StateSetStack;
205
208
209
211 void captureCurrentState(StateSet& stateset) const;
212
215
217 void reset();
218
219 inline const Viewport* getCurrentViewport() const
220 {
222 }
223
224
226
227 inline const osg::Matrix& getInitialViewMatrix() const { return *_initialViewMatrix; }
229
231
232 inline const osg::Matrix& getProjectionMatrix() const { return *_projection; }
233
236
237 const osg::Matrix& getModelViewMatrix() const { return *_modelView; }
238
241
243
245
250
251
253
254
257
258 typedef std::vector<VertexAttribAlias> VertexAttribAliasList;
259
261 void resetVertexAttributeAlias(bool compactAliasing=true, unsigned int numTextureUnits=8);
262
264 void setVertexAlias(const VertexAttribAlias& alias) { _vertexAlias = alias; }
266
268 void setNormalAlias(const VertexAttribAlias& alias) { _normalAlias = alias; }
270
272 void setColorAlias(const VertexAttribAlias& alias) { _colorAlias = alias; }
274
278
280 void setFogCoordAlias(const VertexAttribAlias& alias) { _fogCoordAlias = alias; }
282
284 void setTexCoordAliasList(const VertexAttribAliasList& aliasList) { _texCoordAliasList = aliasList; }
286
288 void setAttributeBindingList(const Program::AttribBindingList& attribBindingList) { _attributeBindingList = attribBindingList; }
290
291 bool convertVertexShaderSourceToOsgBuiltIns(std::string& source) const;
292
293
295 void apply(const StateSet* dstate);
296
301 void apply();
302
305
306
307 void glDrawBuffer(GLenum buffer);
308 GLenum getDrawBuffer() const { return _drawBuffer; }
309
310 void glReadBuffer(GLenum buffer);
311 GLenum getReadBuffer() const { return _readBuffer; }
312
313
316 inline void setModeValidity(StateAttribute::GLMode mode,bool valid)
317 {
318 ModeStack& ms = _modeMap[mode];
319 ms.valid = valid;
320 }
321
325 {
326 ModeStack& ms = _modeMap[mode];
327 return ms.valid;
328 }
329
331 {
332 ModeStack& ms = _modeMap[mode];
333 ms.global_default_value = enabled;
334 }
335
337 {
338 return _modeMap[mode].global_default_value;
339 }
340
342 {
343 return _modeMap[mode].last_applied_value;
344 }
345
348 {
349 inline ApplyModeProxy(osg::State& state, GLenum mode, bool value):_state(state), _mode(mode)
350 {
351 _previous_value = _state.getLastAppliedModeValue(mode);
353 if (_need_to_apply_value) _state.applyMode(_mode, value);
354 }
356 {
358 }
359
361 GLenum _mode;
364 };
365
367 {
368 inline ApplyTextureModeProxy(osg::State& state, unsigned int unit, GLenum mode, bool value):_state(state), _unit(unit), _mode(mode)
369 {
370 _previous_value = _state.getLastAppliedTextureModeValue(_unit, _mode);
372 if (_need_to_apply_value) _state.applyTextureMode(_unit, _mode, value);
373 }
375 {
376 if (_need_to_apply_value) _state.applyTextureMode(_unit, _mode, _previous_value);
377 }
378
380 unsigned int _unit;
381 GLenum _mode;
384 };
385
395 inline bool applyMode(StateAttribute::GLMode mode,bool enabled)
396 {
397 ModeStack& ms = _modeMap[mode];
398 ms.changed = true;
399 return applyMode(mode,enabled,ms);
400 }
401
402 inline void setGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode,bool enabled)
403 {
404 ModeMap& modeMap = getOrCreateTextureModeMap(unit);
405 ModeStack& ms = modeMap[mode];
406 ms.global_default_value = enabled;
407 }
408
409 inline bool getGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode)
410 {
411 ModeMap& modeMap = getOrCreateTextureModeMap(unit);
412 ModeStack& ms = modeMap[mode];
413 return ms.global_default_value;
414 }
415
416 inline bool applyTextureMode(unsigned int unit, StateAttribute::GLMode mode,bool enabled)
417 {
418 ModeMap& modeMap = getOrCreateTextureModeMap(unit);
419 ModeStack& ms = modeMap[mode];
420 ms.changed = true;
421 return applyModeOnTexUnit(unit,mode,enabled,ms);
422 }
423
424 inline bool getLastAppliedTextureModeValue(unsigned int unit, StateAttribute::GLMode mode)
425 {
426 ModeMap& modeMap = getOrCreateTextureModeMap(unit);
427 ModeStack& ms = modeMap[mode];
428 return ms.last_applied_value;
429 }
430
431 inline void setGlobalDefaultAttribute(const StateAttribute* attribute)
432 {
434 as.global_default_attribute = attribute;
435 }
436
437 inline const StateAttribute* getGlobalDefaultAttribute(StateAttribute::Type type, unsigned int member=0)
438 {
440 return as.global_default_attribute.get();
441 }
442
444 inline bool applyAttribute(const StateAttribute* attribute)
445 {
447 as.changed = true;
448 return applyAttribute(attribute,as);
449 }
450
451 inline void setGlobalDefaultTextureAttribute(unsigned int unit, const StateAttribute* attribute)
452 {
453 AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
454 AttributeStack& as = attributeMap[attribute->getTypeMemberPair()];
455 as.global_default_attribute = attribute;
456 }
457
458 inline const StateAttribute* getGlobalDefaultTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member = 0)
459 {
460 AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
461 AttributeStack& as = attributeMap[StateAttribute::TypeMemberPair(type,member)];
462 return as.global_default_attribute.get();
463 }
464
465
466 inline bool applyTextureAttribute(unsigned int unit, const StateAttribute* attribute)
467 {
468 AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
469 AttributeStack& as = attributeMap[attribute->getTypeMemberPair()];
470 as.changed = true;
471 return applyAttributeOnTexUnit(unit,attribute,as);
472 }
473
476
480
482 void haveAppliedAttribute(const StateAttribute* attribute);
483
491 void haveAppliedAttribute(StateAttribute::Type type, unsigned int member=0);
492
495
497 const StateAttribute* getLastAppliedAttribute(StateAttribute::Type type, unsigned int member=0) const;
498
501
504 void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode);
505
507 void haveAppliedTextureAttribute(unsigned int unit, const StateAttribute* attribute);
508
516 void haveAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0);
517
519 bool getLastAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode) const;
520
522 const StateAttribute* getLastAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0) const;
523
524
525
526
527
530
533
534
537 {
538 SetCurrentVertexArrayStateProxy(osg::State& state, VertexArrayState* vas):_state(state) { _state.setCurrentVertexArrayState(vas); }
539 ~SetCurrentVertexArrayStateProxy() { _state.setCurrentToGlobalVertexArrayState(); }
541 };
542
545
548
551
558
559
562
563
564 void lazyDisablingOfVertexAttributes() { _vas->lazyDisablingOfVertexAttributes(); }
565 void applyDisablingOfVertexAttributes() { _vas->applyDisablingOfVertexAttributes(*this); }
566
567 void setCurrentVertexBufferObject(osg::GLBufferObject* vbo) { _vas->setCurrentVertexBufferObject(vbo); }
568 const GLBufferObject* getCurrentVertexBufferObject() { return _vas->getCurrentVertexBufferObject(); }
569
570 void bindVertexBufferObject(osg::GLBufferObject* vbo) { _vas->bindVertexBufferObject(vbo); }
571 void unbindVertexBufferObject() { _vas->unbindVertexBufferObject(); }
572
573 void setCurrentElementBufferObject(osg::GLBufferObject* ebo) { _vas->setCurrentElementBufferObject(ebo); }
574 const GLBufferObject* getCurrentElementBufferObject() { return _vas->getCurrentElementBufferObject(); }
575
576 void bindElementBufferObject(osg::GLBufferObject* ebo) { _vas->bindElementBufferObject(ebo); }
577 void unbindElementBufferObject() { _vas->unbindElementBufferObject(); }
578
579
582
584 {
585 if (pbo)
586 {
587 if (pbo == _currentPBO) return;
588
589 if (pbo->isDirty()) pbo->compileBuffer();
590 else pbo->bindBuffer();
591
592 _currentPBO = pbo;
593 }
594 else
595 {
597 }
598 }
599
601 {
602 if (!_currentPBO) return;
603
605 _currentPBO = 0;
606 }
607
608
610 {
611 if (ibo->isDirty())
612 {
613 ibo->compileBuffer();
614 _currentDIBO = ibo;
615 }
616 else if (ibo != _currentDIBO)
617 {
618 ibo->bindBuffer();
619 _currentDIBO = ibo;
620 }
621 }
622
624 {
625 if (!_currentDIBO) return;
627 _currentDIBO = 0;
628 }
629
630 void setCurrentVertexArrayObject(GLuint vao) { _currentVAO = vao; }
631 GLuint getCurrentVertexArrayObject() const { return _currentVAO; }
632
634
635 inline void bindVertexArrayObject(GLuint vao) { if (_currentVAO!=vao) { _glExtensions->glBindVertexArray(vao); _currentVAO = vao; } }
636
637 inline void unbindVertexArrayObject() { if (_currentVAO!=0) { _glExtensions->glBindVertexArray(0); _currentVAO = 0; } }
638
639
640 typedef std::vector<GLushort> IndicesGLushort;
642
643 typedef std::vector<GLuint> IndicesGLuint;
645
646 void drawQuads(GLint first, GLsizei count, GLsizei primCount=0);
647
648 inline void glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
649 {
650 if (primcount>=1 && _glDrawArraysInstanced!=0) _glDrawArraysInstanced(mode, first, count, primcount);
651 else glDrawArrays(mode, first, count);
652 }
653
654 inline void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount )
655 {
656 if (primcount>=1 && _glDrawElementsInstanced!=0) _glDrawElementsInstanced(mode, count, type, indices, primcount);
657 else glDrawElements(mode, count, type, indices);
658 }
659
660
661 inline void Vertex(float x, float y, float z, float w=1.0f)
662 {
663 #if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
665 else glVertex4f(x,y,z,w);
666 #else
667 _glVertexAttrib4f( _vertexAlias._location, x,y,z,w);
668 #endif
669 }
670
671 inline void Color(float r, float g, float b, float a=1.0f)
672 {
673 #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
675 else glColor4f(r,g,b,a);
676 #else
677 _glVertexAttrib4f( _colorAlias._location, r,g,b,a);
678 #endif
679 }
680
681 void Normal(float x, float y, float z)
682 {
683 #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
685 else glNormal3f(x,y,z);
686 #else
687 _glVertexAttrib4f( _normalAlias._location, x,y,z,0.0);
688 #endif
689 }
690
691 void TexCoord(float x, float y=0.0f, float z=0.0f, float w=1.0f)
692 {
693 #if !defined(OSG_GLES1_AVAILABLE)
694 #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
696 else glTexCoord4f(x,y,z,w);
697 #else
698 _glVertexAttrib4f( _texCoordAliasList[0]._location, x,y,z,w);
699 #endif
700 #endif
701 }
702
703 void MultiTexCoord(unsigned int unit, float x, float y=0.0f, float z=0.0f, float w=1.0f)
704 {
705 #if !defined(OSG_GLES1_AVAILABLE)
706 #ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
708 else _glMultiTexCoord4f(GL_TEXTURE0+unit,x,y,z,w);
709 #else
710 _glVertexAttrib4f( _texCoordAliasList[unit]._location, x,y,z,w);
711 #endif
712 #endif
713 }
714
715 void VerteAttrib(unsigned int location, float x, float y=0.0f, float z=0.0f, float w=0.0f)
716 {
717 _glVertexAttrib4f( location, x,y,z,w);
718 }
719
720
724 void setInterleavedArrays( GLenum format, GLsizei stride, const GLvoid* pointer) { _vas->setInterleavedArrays( *this, format, stride, pointer); }
725
727 inline void setVertexPointer(const Array* array) { _vas->setVertexArray(*this, array); }
728 inline void setVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE) { _vas->setVertexArray( *this, size, type, stride, ptr, normalized); }
729 inline void disableVertexPointer() { _vas->disableVertexArray(*this); }
730
731
732 inline void setNormalPointer(const Array* array) { _vas->setNormalArray(*this, array); }
733 inline void setNormalPointer( GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE ) { _vas->setNormalArray( *this, type, stride, ptr, normalized); }
734 inline void disableNormalPointer() { _vas->disableNormalArray(*this); }
735
736 inline void setColorPointer(const Array* array) { _vas->setColorArray(*this, array); }
737 inline void setColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_TRUE ) { _vas->setColorArray(*this, size, type, stride, ptr, normalized); }
738 inline void disableColorPointer() { _vas->disableColorArray(*this); }
739
741 inline void setSecondaryColorPointer(const Array* array) { _vas->setSecondaryColorArray(*this, array); }
742 inline void disableSecondaryColorPointer() { _vas->disableSecondaryColorArray(*this); }
743
744 inline bool isFogCoordSupported() const { return _isFogCoordSupported; }
745 inline void setFogCoordPointer(const Array* array) { _vas->setFogCoordArray(*this, array); }
746 inline void disableFogCoordPointer() { _vas->disableFogCoordArray(*this); }
747
748
749 inline void setTexCoordPointer(unsigned int unit, const Array* array) { _vas->setTexCoordArray(*this, unit, array); }
750 inline void setTexCoordPointer( unsigned int unit, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE ) { _vas->setTexCoordArray(*this, unit, size, type, stride, ptr, normalized); }
751 inline void disableTexCoordPointer( unsigned int unit ) { _vas->disableTexCoordArray(*this, unit); }
752 inline void disableTexCoordPointersAboveAndIncluding( unsigned int unit ) { _vas->disableTexCoordArrayAboveAndIncluding(*this, unit); }
753
755 inline GLint getMaxTextureCoords() const { return _glMaxTextureCoords; }
756
758 inline GLint getMaxTextureUnits() const { return _glMaxTextureUnits; }
759
760
764 inline bool setActiveTextureUnit( unsigned int unit );
765
767 unsigned int getActiveTextureUnit() const { return _currentActiveTextureUnit; }
768
772 bool setClientActiveTextureUnit( unsigned int unit );
773
775 unsigned int getClientActiveTextureUnit() const;
776
777 inline void setVertexAttribPointer(unsigned int unit, const Array* array) { _vas->setVertexAttribArray(*this, unit, array); }
778 inline void setVertexAttribLPointer(unsigned int unit, const Array* array) { _vas->setVertexAttribArray(*this, unit, array); }
779 inline void setVertexAttribIPointer(unsigned int unit, const Array* array) { _vas->setVertexAttribArray(*this, unit, array); }
780
781 inline void disableVertexAttribPointer( unsigned int index ) { _vas->disableVertexAttribArray(*this, index); }
782 inline void disableVertexAttribPointersAboveAndIncluding( unsigned int index ) { _vas->disableVertexAttribArray(*this, index); }
783
784
787
788
790 inline bool useVertexBufferObject(bool useVBO) const { return _forceVertexBufferObject || (_isVertexBufferObjectSupported && useVBO); }
791
793 inline bool useVertexArrayObject(bool useVAO) const { return _forceVertexArrayObject || (_isVertexArrayObjectSupported && useVAO); }
794
795
797 {
798 if (_lastAppliedProgramObject!=program)
799 {
801 }
802 }
804
805 inline GLint getUniformLocation( unsigned int uniformNameID ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getUniformLocation(uniformNameID) : -1; }
814 inline GLint getUniformLocation( const std::string & uniformName ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getUniformLocation(uniformName) : -1; }
815 inline GLint getAttribLocation( const std::string& name ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getAttribLocation(name) : -1; }
816
817 typedef std::pair<const StateAttribute*,StateAttribute::OverrideValue> AttributePair;
818 typedef std::vector<AttributePair> AttributeVec;
819
821 {
822 AttributeStack& as = _attributeMap[ attribute->getTypeMemberPair() ];
823 return as.attributeVec;
824 }
825
827 inline void setFrameStamp(FrameStamp* fs) { _frameStamp = fs; }
828
830 inline FrameStamp* getFrameStamp() { return _frameStamp.get(); }
831
833 inline const FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
834
835
840
842 inline const DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
843
846
849
850
852 void setAbortRenderingPtr(bool* abortPtr) { _abortRenderingPtr = abortPtr; }
853
856 bool getAbortRendering() const { return _abortRenderingPtr!=0?(*_abortRenderingPtr):false; }
857
858
860 {
861 virtual void completed(osg::State*) = 0;
862 };
863
866
869
871 void setDynamicObjectCount(unsigned int count, bool callCallbackOnZero = false)
872 {
873 if (_dynamicObjectCount != count)
874 {
875 _dynamicObjectCount = count;
876 if (_dynamicObjectCount==0 && callCallbackOnZero && _completeDynamicObjectRenderingCallback.valid())
877 {
879 }
880 }
881 }
882
884 unsigned int getDynamicObjectCount() const { return _dynamicObjectCount; }
885
896
897 void setMaxTexturePoolSize(unsigned int size);
898 unsigned int getMaxTexturePoolSize() const { return _maxTexturePoolSize; }
899
900 void setMaxBufferObjectPoolSize(unsigned int size);
902
903
918
921
924
925 bool checkGLErrors(const char* str1=0, const char* str2=0) const;
927 bool checkGLErrors(const StateAttribute* attribute) const;
928
930 void print(std::ostream& fout) const;
931
934
937
938
941
944
947
948
949
954 Timer_t getStartTick() const { return _startTick; }
955 void setStartTick(Timer_t tick) { _startTick = tick; }
956 Timer_t getGpuTick() const { return _gpuTick; }
957
958 double getGpuTime() const
959 {
961 }
962 GLuint64 getGpuTimestamp() const { return _gpuTimestamp; }
963
964 void setGpuTimestamp(Timer_t tick, GLuint64 timestamp)
965 {
966 _gpuTick = tick;
967 _gpuTimestamp = timestamp;
968 }
969 int getTimestampBits() const { return _timestampBits; }
970 void setTimestampBits(int bits) { _timestampBits = bits; }
971
973 virtual void frameCompleted();
974
975
977 {
978 typedef std::vector<StateAttribute::GLModeValue> ValueVec;
979
981 {
982 valid = true;
983 changed = false;
984 last_applied_value = false;
985 global_default_value = false;
986 }
987
988 void print(std::ostream& fout) const;
989
990 bool valid;
995 };
996
1017
1018
1020 {
1021 typedef std::pair<const Uniform*,StateAttribute::OverrideValue> UniformPair;
1022 typedef std::vector<UniformPair> UniformVec;
1023
1025
1026 void print(std::ostream& fout) const;
1027
1029 };
1030
1032 {
1033 typedef std::vector<StateSet::DefinePair> DefineVec;
1034
1036 changed(false) {}
1037
1038 void print(std::ostream& fout) const;
1039
1042 };
1043
1045 {
1047 changed(false) {}
1048
1049 typedef std::map<std::string, DefineStack> DefineStackMap;
1053
1055
1056 };
1057
1058 typedef std::map<StateAttribute::GLMode,ModeStack> ModeMap;
1059 typedef std::vector<ModeMap> TextureModeMapList;
1060
1061 typedef std::map<StateAttribute::TypeMemberPair,AttributeStack> AttributeMap;
1062 typedef std::vector<AttributeMap> TextureAttributeMapList;
1063
1064 typedef std::map<std::string, UniformStack> UniformMap;
1065
1066
1067 typedef std::vector< ref_ptr<const Matrix> > MatrixStack;
1068
1069 inline const ModeMap& getModeMap() const {return _modeMap;}
1070 inline const AttributeMap& getAttributeMap() const {return _attributeMap;}
1071 inline const UniformMap& getUniformMap() const {return _uniformMap;}
1073 inline const DefineMap& getDefineMap() const {return _defineMap;}
1076
1077 std::string getDefineString(const osg::ShaderDefines& shaderDefines);
1078 bool supportsShaderRequirements(const osg::ShaderDefines& shaderRequirements);
1079 bool supportsShaderRequirement(const std::string& shaderRequirement);
1080
1081 protected:
1082
1083 virtual ~State();
1084
1086 unsigned int _contextID;
1087
1090
1096
1098
1101
1107
1113
1115
1117
1120
1121
1129
1131
1132 void setUpVertexAttribAlias(VertexAttribAlias& alias, GLuint location, const std::string glName, const std::string osgName, const std::string& declaration);
1133
1143 inline bool applyMode(StateAttribute::GLMode mode,bool enabled,ModeStack& ms)
1144 {
1145 if (ms.valid && ms.last_applied_value != enabled)
1146 {
1147 ms.last_applied_value = enabled;
1148
1149 if (enabled) glEnable(mode);
1150 else glDisable(mode);
1151
1153
1154 return true;
1155 }
1156 else
1157 return false;
1158 }
1159
1160 inline bool applyModeOnTexUnit(unsigned int unit,StateAttribute::GLMode mode,bool enabled,ModeStack& ms)
1161 {
1162 if (ms.valid && ms.last_applied_value != enabled)
1163 {
1164 if (setActiveTextureUnit(unit))
1165 {
1166 ms.last_applied_value = enabled;
1167
1168 if (enabled) glEnable(mode);
1169 else glDisable(mode);
1170
1172
1173 return true;
1174 }
1175 else
1176 return false;
1177 }
1178 else
1179 return false;
1180 }
1181
1183 inline bool applyAttribute(const StateAttribute* attribute,AttributeStack& as)
1184 {
1185 if (as.last_applied_attribute != attribute)
1186 {
1188
1189 as.last_applied_attribute = attribute;
1190 attribute->apply(*this);
1191
1192 const ShaderComponent* sc = attribute->getShaderComponent();
1193 if (as.last_applied_shadercomponent != sc)
1194 {
1197 }
1198
1200
1201 return true;
1202 }
1203 else
1204 return false;
1205 }
1206
1207 inline bool applyAttributeOnTexUnit(unsigned int unit,const StateAttribute* attribute,AttributeStack& as)
1208 {
1209 if (as.last_applied_attribute != attribute)
1210 {
1211 if (setActiveTextureUnit(unit))
1212 {
1214
1215 as.last_applied_attribute = attribute;
1216 attribute->apply(*this);
1217
1218 const ShaderComponent* sc = attribute->getShaderComponent();
1219 if (as.last_applied_shadercomponent != sc)
1220 {
1223 }
1224
1226
1227 return true;
1228 }
1229 else
1230 return false;
1231 }
1232 else
1233 return false;
1234 }
1235
1236
1238 {
1240 {
1242 if (as.global_default_attribute.valid())
1243 {
1244 as.global_default_attribute->apply(*this);
1245 const ShaderComponent* sc = as.global_default_attribute->getShaderComponent();
1246 if (as.last_applied_shadercomponent != sc)
1247 {
1250 }
1251
1253 }
1254 return true;
1255 }
1256 else
1257 return false;
1258 }
1259
1260 inline bool applyGlobalDefaultAttributeOnTexUnit(unsigned int unit,AttributeStack& as)
1261 {
1263 {
1264 if (setActiveTextureUnit(unit))
1265 {
1267 if (as.global_default_attribute.valid())
1268 {
1269 as.global_default_attribute->apply(*this);
1270 const ShaderComponent* sc = as.global_default_attribute->getShaderComponent();
1271 if (as.last_applied_shadercomponent != sc)
1272 {
1275 }
1277 }
1278 return true;
1279 }
1280 else
1281 return false;
1282 }
1283 else
1284 return false;
1285 }
1286
1291
1294
1296
1298
1301
1302
1308
1309
1310 inline ModeMap& getOrCreateTextureModeMap(unsigned int unit)
1311 {
1312 if (unit>=_textureModeMapList.size()) _textureModeMapList.resize(unit+1);
1313 return _textureModeMapList[unit];
1314 }
1315
1316
1318 {
1319 if (unit>=_textureAttributeMapList.size()) _textureAttributeMapList.resize(unit+1);
1320 return _textureAttributeMapList[unit];
1321 }
1322
1323 inline void pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeList);
1324 inline void pushAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
1325 inline void pushUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList);
1326 inline void pushDefineList(DefineMap& defineMap,const StateSet::DefineList& defineList);
1327
1328 inline void popModeList(ModeMap& modeMap,const StateSet::ModeList& modeList);
1329 inline void popAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
1330 inline void popUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList);
1331 inline void popDefineList(DefineMap& uniformMap,const StateSet::DefineList& defineList);
1332
1333 inline void applyModeList(ModeMap& modeMap,const StateSet::ModeList& modeList);
1334 inline void applyAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
1335 inline void applyUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList);
1336 inline void applyDefineList(DefineMap& uniformMap,const StateSet::DefineList& defineList);
1337
1338 inline void applyModeMap(ModeMap& modeMap);
1339 inline void applyAttributeMap(AttributeMap& attributeMap);
1340 inline void applyUniformMap(UniformMap& uniformMap);
1341
1342 inline void applyModeListOnTexUnit(unsigned int unit,ModeMap& modeMap,const StateSet::ModeList& modeList);
1343 inline void applyAttributeListOnTexUnit(unsigned int unit,AttributeMap& attributeMap,const StateSet::AttributeList& attributeList);
1344
1345 inline void applyModeMapOnTexUnit(unsigned int unit,ModeMap& modeMap);
1346 inline void applyAttributeMapOnTexUnit(unsigned int unit,AttributeMap& attributeMap);
1347
1350 void haveAppliedAttribute(AttributeMap& attributeMap,const StateAttribute* attribute);
1351 void haveAppliedAttribute(AttributeMap& attributeMap,StateAttribute::Type type, unsigned int member);
1352 bool getLastAppliedMode(const ModeMap& modeMap,StateAttribute::GLMode mode) const;
1353 const StateAttribute* getLastAppliedAttribute(const AttributeMap& attributeMap,StateAttribute::Type type, unsigned int member) const;
1354
1356
1357
1364
1365 typedef void (GL_APIENTRY * ActiveTextureProc) (GLenum texture);
1366 typedef void (GL_APIENTRY * FogCoordPointerProc) (GLenum type, GLsizei stride, const GLvoid *pointer);
1367 typedef void (GL_APIENTRY * SecondaryColorPointerProc) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
1368 typedef void (GL_APIENTRY * MultiTexCoord4fProc) (GLenum target, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1369 typedef void (GL_APIENTRY * VertexAttrib4fProc)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1370 typedef void (GL_APIENTRY * VertexAttrib4fvProc)(GLuint index, const GLfloat *v);
1371 typedef void (GL_APIENTRY * VertexAttribPointerProc) (unsigned int, GLint, GLenum, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
1372 typedef void (GL_APIENTRY * VertexAttribIPointerProc) (unsigned int, GLint, GLenum, GLsizei stride, const GLvoid *pointer);
1373 typedef void (GL_APIENTRY * VertexAttribLPointerProc) (unsigned int, GLint, GLenum, GLsizei stride, const GLvoid *pointer);
1374 typedef void (GL_APIENTRY * EnableVertexAttribProc) (unsigned int);
1375 typedef void (GL_APIENTRY * DisableVertexAttribProc) (unsigned int);
1376 typedef void (GL_APIENTRY * BindBufferProc) (GLenum target, GLuint buffer);
1377
1378 typedef void (GL_APIENTRY * DrawArraysInstancedProc)( GLenum mode, GLint first, GLsizei count, GLsizei primcount );
1379 typedef void (GL_APIENTRY * DrawElementsInstancedProc)( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount );
1380
1399
1401
1404
1406
1408
1413};
1414
1415inline void State::pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
1416{
1417 for(StateSet::ModeList::const_iterator mitr=modeList.begin();
1418 mitr!=modeList.end();
1419 ++mitr)
1420 {
1421 // get the mode stack for incoming GLmode {mitr->first}.
1422 ModeStack& ms = modeMap[mitr->first];
1423 if (ms.valueVec.empty())
1424 {
1425 // first pair so simply push incoming pair to back.
1426 ms.valueVec.push_back(mitr->second);
1427 }
1428 else if ((ms.valueVec.back() & StateAttribute::OVERRIDE) && !(mitr->second & StateAttribute::PROTECTED)) // check the existing override flag
1429 {
1430 // push existing back since override keeps the previous value.
1431 ms.valueVec.push_back(ms.valueVec.back());
1432 }
1433 else
1434 {
1435 // no override on so simply push incoming pair to back.
1436 ms.valueVec.push_back(mitr->second);
1437 }
1438 ms.changed = true;
1439 }
1440}
1441
1442inline void State::pushAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
1443{
1444 for(StateSet::AttributeList::const_iterator aitr=attributeList.begin();
1445 aitr!=attributeList.end();
1446 ++aitr)
1447 {
1448 // get the attribute stack for incoming type {aitr->first}.
1449 AttributeStack& as = attributeMap[aitr->first];
1450 if (as.attributeVec.empty())
1451 {
1452 // first pair so simply push incoming pair to back.
1453 as.attributeVec.push_back(
1454 AttributePair(aitr->second.first.get(),aitr->second.second));
1455 }
1456 else if ((as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag
1457 {
1458 // push existing back since override keeps the previous value.
1459 as.attributeVec.push_back(as.attributeVec.back());
1460 }
1461 else
1462 {
1463 // no override on so simply push incoming pair to back.
1464 as.attributeVec.push_back(
1465 AttributePair(aitr->second.first.get(),aitr->second.second));
1466 }
1467 as.changed = true;
1468 }
1469}
1470
1471
1472inline void State::pushUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList)
1473{
1474 for(StateSet::UniformList::const_iterator aitr=uniformList.begin();
1475 aitr!=uniformList.end();
1476 ++aitr)
1477 {
1478 // get the attribute stack for incoming type {aitr->first}.
1479 UniformStack& us = uniformMap[aitr->first];
1480 if (us.uniformVec.empty())
1481 {
1482 // first pair so simply push incoming pair to back.
1483 us.uniformVec.push_back(
1484 UniformStack::UniformPair(aitr->second.first.get(),aitr->second.second));
1485 }
1486 else if ((us.uniformVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag
1487 {
1488 // push existing back since override keeps the previous value.
1489 us.uniformVec.push_back(us.uniformVec.back());
1490 }
1491 else
1492 {
1493 // no override on so simply push incoming pair to back.
1494 us.uniformVec.push_back(
1495 UniformStack::UniformPair(aitr->second.first.get(),aitr->second.second));
1496 }
1497 }
1498}
1499
1500inline void State::pushDefineList(DefineMap& defineMap,const StateSet::DefineList& defineList)
1501{
1502 for(StateSet::DefineList::const_iterator aitr=defineList.begin();
1503 aitr!=defineList.end();
1504 ++aitr)
1505 {
1506 // get the attribute stack for incoming type {aitr->first}.
1507 DefineStack& ds = defineMap.map[aitr->first];
1509 if (dv.empty())
1510 {
1511 // first pair so simply push incoming pair to back.
1512 dv.push_back(StateSet::DefinePair(aitr->second.first,aitr->second.second));
1513
1514 ds.changed = true;
1515 defineMap.changed = true;
1516 }
1517 else if ((ds.defineVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag
1518 {
1519 // push existing back since override keeps the previous value.
1520 ds.defineVec.push_back(ds.defineVec.back());
1521 }
1522 else
1523 {
1524 // no override on so simply push incoming pair to back.
1525 dv.push_back(StateSet::DefinePair(aitr->second.first,aitr->second.second));
1526
1527 // if the back of the stack has changed since the last then mark it as changed.
1528 bool changed = (dv[dv.size()-2] != dv.back());
1529 if (changed)
1530 {
1531 ds.changed = true;
1532 defineMap.changed = true;
1533 }
1534 }
1535 }
1536}
1537
1538inline void State::popModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
1539{
1540 for(StateSet::ModeList::const_iterator mitr=modeList.begin();
1541 mitr!=modeList.end();
1542 ++mitr)
1543 {
1544 // get the mode stack for incoming GLmode {mitr->first}.
1545 ModeStack& ms = modeMap[mitr->first];
1546 if (!ms.valueVec.empty())
1547 {
1548 ms.valueVec.pop_back();
1549 }
1550 ms.changed = true;
1551 }
1552}
1553
1554inline void State::popAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
1555{
1556 for(StateSet::AttributeList::const_iterator aitr=attributeList.begin();
1557 aitr!=attributeList.end();
1558 ++aitr)
1559 {
1560 // get the attribute stack for incoming type {aitr->first}.
1561 AttributeStack& as = attributeMap[aitr->first];
1562 if (!as.attributeVec.empty())
1563 {
1564 as.attributeVec.pop_back();
1565 }
1566 as.changed = true;
1567 }
1568}
1569
1570inline void State::popUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList)
1571{
1572 for(StateSet::UniformList::const_iterator aitr=uniformList.begin();
1573 aitr!=uniformList.end();
1574 ++aitr)
1575 {
1576 // get the attribute stack for incoming type {aitr->first}.
1577 UniformStack& us = uniformMap[aitr->first];
1578 if (!us.uniformVec.empty())
1579 {
1580 us.uniformVec.pop_back();
1581 }
1582 }
1583}
1584
1585inline void State::popDefineList(DefineMap& defineMap,const StateSet::DefineList& defineList)
1586{
1587 for(StateSet::DefineList::const_iterator aitr=defineList.begin();
1588 aitr!=defineList.end();
1589 ++aitr)
1590 {
1591 // get the attribute stack for incoming type {aitr->first}.
1592 DefineStack& ds = defineMap.map[aitr->first];
1594 if (!dv.empty())
1595 {
1596 // if the stack has less than 2 entries or new back vs old back are different then mark the DefineStack as changed
1597 if ((dv.size() < 2) || (dv[dv.size()-2] != dv.back()))
1598 {
1599 ds.changed = true;
1600 defineMap.changed = true;
1601 }
1602 dv.pop_back();
1603 }
1604 }
1605}
1606
1607inline void State::applyModeList(ModeMap& modeMap,const StateSet::ModeList& modeList)
1608{
1609 StateSet::ModeList::const_iterator ds_mitr = modeList.begin();
1610 ModeMap::iterator this_mitr=modeMap.begin();
1611
1612 while (this_mitr!=modeMap.end() && ds_mitr!=modeList.end())
1613 {
1614 if (this_mitr->first<ds_mitr->first)
1615 {
1616
1617 // note GLMode = this_mitr->first
1618 ModeStack& ms = this_mitr->second;
1619 if (ms.changed)
1620 {
1621 ms.changed = false;
1622 if (!ms.valueVec.empty())
1623 {
1624 bool new_value = ms.valueVec.back() & StateAttribute::ON;
1625 applyMode(this_mitr->first,new_value,ms);
1626 }
1627 else
1628 {
1629 // assume default of disabled.
1630 applyMode(this_mitr->first,ms.global_default_value,ms);
1631
1632 }
1633
1634 }
1635
1636 ++this_mitr;
1637
1638 }
1639 else if (ds_mitr->first<this_mitr->first)
1640 {
1641
1642 // ds_mitr->first is a new mode, therefore
1643 // need to insert a new mode entry for ds_mistr->first.
1644 ModeStack& ms = modeMap[ds_mitr->first];
1645
1646 bool new_value = ds_mitr->second & StateAttribute::ON;
1647 applyMode(ds_mitr->first,new_value,ms);
1648
1649 // will need to disable this mode on next apply so set it to changed.
1650 ms.changed = true;
1651
1652 ++ds_mitr;
1653
1654 }
1655 else
1656 {
1657 // this_mitr & ds_mitr refer to the same mode, check the override
1658 // if any otherwise just apply the incoming mode.
1659
1660 ModeStack& ms = this_mitr->second;
1661
1662 if (!ms.valueVec.empty() && (ms.valueVec.back() & StateAttribute::OVERRIDE) && !(ds_mitr->second & StateAttribute::PROTECTED))
1663 {
1664 // override is on, just treat as a normal apply on modes.
1665
1666 if (ms.changed)
1667 {
1668 ms.changed = false;
1669 bool new_value = ms.valueVec.back() & StateAttribute::ON;
1670 applyMode(this_mitr->first,new_value,ms);
1671
1672 }
1673 }
1674 else
1675 {
1676 // no override on or no previous entry, therefore consider incoming mode.
1677 bool new_value = ds_mitr->second & StateAttribute::ON;
1678 if (applyMode(ds_mitr->first,new_value,ms))
1679 {
1680 ms.changed = true;
1681 }
1682 }
1683
1684 ++this_mitr;
1685 ++ds_mitr;
1686 }
1687 }
1688
1689 // iterator over the remaining state modes to apply any previous changes.
1690 for(;
1691 this_mitr!=modeMap.end();
1692 ++this_mitr)
1693 {
1694 // note GLMode = this_mitr->first
1695 ModeStack& ms = this_mitr->second;
1696 if (ms.changed)
1697 {
1698 ms.changed = false;
1699 if (!ms.valueVec.empty())
1700 {
1701 bool new_value = ms.valueVec.back() & StateAttribute::ON;
1702 applyMode(this_mitr->first,new_value,ms);
1703 }
1704 else
1705 {
1706 // assume default of disabled.
1707 applyMode(this_mitr->first,ms.global_default_value,ms);
1708
1709 }
1710
1711 }
1712 }
1713
1714 // iterator over the remaining incoming modes to apply any new mode.
1715 for(;
1716 ds_mitr!=modeList.end();
1717 ++ds_mitr)
1718 {
1719 ModeStack& ms = modeMap[ds_mitr->first];
1720
1721 bool new_value = ds_mitr->second & StateAttribute::ON;
1722 applyMode(ds_mitr->first,new_value,ms);
1723
1724 // will need to disable this mode on next apply so set it to changed.
1725 ms.changed = true;
1726 }
1727}
1728
1729inline void State::applyModeListOnTexUnit(unsigned int unit,ModeMap& modeMap,const StateSet::ModeList& modeList)
1730{
1731 StateSet::ModeList::const_iterator ds_mitr = modeList.begin();
1732 ModeMap::iterator this_mitr=modeMap.begin();
1733
1734 while (this_mitr!=modeMap.end() && ds_mitr!=modeList.end())
1735 {
1736 if (this_mitr->first<ds_mitr->first)
1737 {
1738
1739 // note GLMode = this_mitr->first
1740 ModeStack& ms = this_mitr->second;
1741 if (ms.changed)
1742 {
1743 ms.changed = false;
1744 if (!ms.valueVec.empty())
1745 {
1746 bool new_value = ms.valueVec.back() & StateAttribute::ON;
1747 applyModeOnTexUnit(unit,this_mitr->first,new_value,ms);
1748 }
1749 else
1750 {
1751 // assume default of disabled.
1752 applyModeOnTexUnit(unit,this_mitr->first,ms.global_default_value,ms);
1753
1754 }
1755
1756 }
1757
1758 ++this_mitr;
1759
1760 }
1761 else if (ds_mitr->first<this_mitr->first)
1762 {
1763
1764 // ds_mitr->first is a new mode, therefore
1765 // need to insert a new mode entry for ds_mistr->first.
1766 ModeStack& ms = modeMap[ds_mitr->first];
1767
1768 bool new_value = ds_mitr->second & StateAttribute::ON;
1769 applyModeOnTexUnit(unit,ds_mitr->first,new_value,ms);
1770
1771 // will need to disable this mode on next apply so set it to changed.
1772 ms.changed = true;
1773
1774 ++ds_mitr;
1775
1776 }
1777 else
1778 {
1779 // this_mitr & ds_mitr refer to the same mode, check the override
1780 // if any otherwise just apply the incoming mode.
1781
1782 ModeStack& ms = this_mitr->second;
1783
1784 if (!ms.valueVec.empty() && (ms.valueVec.back() & StateAttribute::OVERRIDE) && !(ds_mitr->second & StateAttribute::PROTECTED))
1785 {
1786 // override is on, just treat as a normal apply on modes.
1787
1788 if (ms.changed)
1789 {
1790 ms.changed = false;
1791 bool new_value = ms.valueVec.back() & StateAttribute::ON;
1792 applyModeOnTexUnit(unit,this_mitr->first,new_value,ms);
1793
1794 }
1795 }
1796 else
1797 {
1798 // no override on or no previous entry, therefore consider incoming mode.
1799 bool new_value = ds_mitr->second & StateAttribute::ON;
1800 if (applyModeOnTexUnit(unit,ds_mitr->first,new_value,ms))
1801 {
1802 ms.changed = true;
1803 }
1804 }
1805
1806 ++this_mitr;
1807 ++ds_mitr;
1808 }
1809 }
1810
1811 // iterator over the remaining state modes to apply any previous changes.
1812 for(;
1813 this_mitr!=modeMap.end();
1814 ++this_mitr)
1815 {
1816 // note GLMode = this_mitr->first
1817 ModeStack& ms = this_mitr->second;
1818 if (ms.changed)
1819 {
1820 ms.changed = false;
1821 if (!ms.valueVec.empty())
1822 {
1823 bool new_value = ms.valueVec.back() & StateAttribute::ON;
1824 applyModeOnTexUnit(unit,this_mitr->first,new_value,ms);
1825 }
1826 else
1827 {
1828 // assume default of disabled.
1829 applyModeOnTexUnit(unit,this_mitr->first,ms.global_default_value,ms);
1830
1831 }
1832
1833 }
1834 }
1835
1836 // iterator over the remaining incoming modes to apply any new mode.
1837 for(;
1838 ds_mitr!=modeList.end();
1839 ++ds_mitr)
1840 {
1841 ModeStack& ms = modeMap[ds_mitr->first];
1842
1843 bool new_value = ds_mitr->second & StateAttribute::ON;
1844 applyModeOnTexUnit(unit,ds_mitr->first,new_value,ms);
1845
1846 // will need to disable this mode on next apply so set it to changed.
1847 ms.changed = true;
1848 }
1849}
1850
1851inline void State::applyAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
1852{
1853 StateSet::AttributeList::const_iterator ds_aitr=attributeList.begin();
1854
1855 AttributeMap::iterator this_aitr=attributeMap.begin();
1856
1857 while (this_aitr!=attributeMap.end() && ds_aitr!=attributeList.end())
1858 {
1859 if (this_aitr->first<ds_aitr->first)
1860 {
1861
1862 // note attribute type = this_aitr->first
1863 AttributeStack& as = this_aitr->second;
1864 if (as.changed)
1865 {
1866 as.changed = false;
1867 if (!as.attributeVec.empty())
1868 {
1869 const StateAttribute* new_attr = as.attributeVec.back().first;
1870 applyAttribute(new_attr,as);
1871 }
1872 else
1873 {
1875 }
1876 }
1877
1878 ++this_aitr;
1879
1880 }
1881 else if (ds_aitr->first<this_aitr->first)
1882 {
1883
1884 // ds_aitr->first is a new attribute, therefore
1885 // need to insert a new attribute entry for ds_aitr->first.
1886 AttributeStack& as = attributeMap[ds_aitr->first];
1887
1888 const StateAttribute* new_attr = ds_aitr->second.first.get();
1889 applyAttribute(new_attr,as);
1890
1891 as.changed = true;
1892
1893 ++ds_aitr;
1894
1895 }
1896 else
1897 {
1898 // this_mitr & ds_mitr refer to the same attribute, check the override
1899 // if any otherwise just apply the incoming attribute
1900
1901 AttributeStack& as = this_aitr->second;
1902
1903 if (!as.attributeVec.empty() && (as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(ds_aitr->second.second & StateAttribute::PROTECTED))
1904 {
1905 // override is on, just treat as a normal apply on attribute.
1906
1907 if (as.changed)
1908 {
1909 as.changed = false;
1910 const StateAttribute* new_attr = as.attributeVec.back().first;
1911 applyAttribute(new_attr,as);
1912 }
1913 }
1914 else
1915 {
1916 // no override on or no previous entry, therefore consider incoming attribute.
1917 const StateAttribute* new_attr = ds_aitr->second.first.get();
1918 if (applyAttribute(new_attr,as))
1919 {
1920 as.changed = true;
1921 }
1922 }
1923
1924 ++this_aitr;
1925 ++ds_aitr;
1926 }
1927 }
1928
1929 // iterator over the remaining state attributes to apply any previous changes.
1930 for(;
1931 this_aitr!=attributeMap.end();
1932 ++this_aitr)
1933 {
1934 // note attribute type = this_aitr->first
1935 AttributeStack& as = this_aitr->second;
1936 if (as.changed)
1937 {
1938 as.changed = false;
1939 if (!as.attributeVec.empty())
1940 {
1941 const StateAttribute* new_attr = as.attributeVec.back().first;
1942 applyAttribute(new_attr,as);
1943 }
1944 else
1945 {
1947 }
1948 }
1949 }
1950
1951 // iterator over the remaining incoming attribute to apply any new attribute.
1952 for(;
1953 ds_aitr!=attributeList.end();
1954 ++ds_aitr)
1955 {
1956 // ds_aitr->first is a new attribute, therefore
1957 // need to insert a new attribute entry for ds_aitr->first.
1958 AttributeStack& as = attributeMap[ds_aitr->first];
1959
1960 const StateAttribute* new_attr = ds_aitr->second.first.get();
1961 applyAttribute(new_attr,as);
1962
1963 // will need to update this attribute on next apply so set it to changed.
1964 as.changed = true;
1965 }
1966
1967}
1968
1969inline void State::applyAttributeListOnTexUnit(unsigned int unit,AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
1970{
1971 StateSet::AttributeList::const_iterator ds_aitr=attributeList.begin();
1972
1973 AttributeMap::iterator this_aitr=attributeMap.begin();
1974
1975 while (this_aitr!=attributeMap.end() && ds_aitr!=attributeList.end())
1976 {
1977 if (this_aitr->first<ds_aitr->first)
1978 {
1979
1980 // note attribute type = this_aitr->first
1981 AttributeStack& as = this_aitr->second;
1982 if (as.changed)
1983 {
1984 as.changed = false;
1985 if (!as.attributeVec.empty())
1986 {
1987 const StateAttribute* new_attr = as.attributeVec.back().first;
1988 applyAttributeOnTexUnit(unit,new_attr,as);
1989 }
1990 else
1991 {
1993 }
1994 }
1995
1996 ++this_aitr;
1997
1998 }
1999 else if (ds_aitr->first<this_aitr->first)
2000 {
2001
2002 // ds_aitr->first is a new attribute, therefore
2003 // need to insert a new attribute entry for ds_aitr->first.
2004 AttributeStack& as = attributeMap[ds_aitr->first];
2005
2006 const StateAttribute* new_attr = ds_aitr->second.first.get();
2007 applyAttributeOnTexUnit(unit,new_attr,as);
2008
2009 as.changed = true;
2010
2011 ++ds_aitr;
2012
2013 }
2014 else
2015 {
2016 // this_mitr & ds_mitr refer to the same attribute, check the override
2017 // if any otherwise just apply the incoming attribute
2018
2019 AttributeStack& as = this_aitr->second;
2020
2021 if (!as.attributeVec.empty() && (as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(ds_aitr->second.second & StateAttribute::PROTECTED))
2022 {
2023 // override is on, just treat as a normal apply on attribute.
2024
2025 if (as.changed)
2026 {
2027 as.changed = false;
2028 const StateAttribute* new_attr = as.attributeVec.back().first;
2029 applyAttributeOnTexUnit(unit,new_attr,as);
2030 }
2031 }
2032 else
2033 {
2034 // no override on or no previous entry, therefore consider incoming attribute.
2035 const StateAttribute* new_attr = ds_aitr->second.first.get();
2036 if (applyAttributeOnTexUnit(unit,new_attr,as))
2037 {
2038 as.changed = true;
2039 }
2040 }
2041
2042 ++this_aitr;
2043 ++ds_aitr;
2044 }
2045 }
2046
2047 // iterator over the remaining state attributes to apply any previous changes.
2048 for(;
2049 this_aitr!=attributeMap.end();
2050 ++this_aitr)
2051 {
2052 // note attribute type = this_aitr->first
2053 AttributeStack& as = this_aitr->second;
2054 if (as.changed)
2055 {
2056 as.changed = false;
2057 if (!as.attributeVec.empty())
2058 {
2059 const StateAttribute* new_attr = as.attributeVec.back().first;
2060 applyAttributeOnTexUnit(unit,new_attr,as);
2061 }
2062 else
2063 {
2065 }
2066 }
2067 }
2068
2069 // iterator over the remaining incoming attribute to apply any new attribute.
2070 for(;
2071 ds_aitr!=attributeList.end();
2072 ++ds_aitr)
2073 {
2074 // ds_aitr->first is a new attribute, therefore
2075 // need to insert a new attribute entry for ds_aitr->first.
2076 AttributeStack& as = attributeMap[ds_aitr->first];
2077
2078 const StateAttribute* new_attr = ds_aitr->second.first.get();
2079 applyAttributeOnTexUnit(unit,new_attr,as);
2080
2081 // will need to update this attribute on next apply so set it to changed.
2082 as.changed = true;
2083 }
2084
2085}
2086
2087inline void State::applyUniformList(UniformMap& uniformMap,const StateSet::UniformList& uniformList)
2088{
2089 if (!_lastAppliedProgramObject) return;
2090
2091 StateSet::UniformList::const_iterator ds_aitr=uniformList.begin();
2092
2093 UniformMap::iterator this_aitr=uniformMap.begin();
2094
2095 while (this_aitr!=uniformMap.end() && ds_aitr!=uniformList.end())
2096 {
2097 if (this_aitr->first<ds_aitr->first)
2098 {
2099 // note attribute type = this_aitr->first
2100 UniformStack& as = this_aitr->second;
2101 if (!as.uniformVec.empty())
2102 {
2103 _lastAppliedProgramObject->apply(*as.uniformVec.back().first);
2104 }
2105
2106 ++this_aitr;
2107
2108 }
2109 else if (ds_aitr->first<this_aitr->first)
2110 {
2111 _lastAppliedProgramObject->apply(*(ds_aitr->second.first.get()));
2112
2113 ++ds_aitr;
2114 }
2115 else
2116 {
2117 // this_mitr & ds_mitr refer to the same attribute, check the override
2118 // if any otherwise just apply the incoming attribute
2119
2120 UniformStack& as = this_aitr->second;
2121
2122 if (!as.uniformVec.empty() && (as.uniformVec.back().second & StateAttribute::OVERRIDE) && !(ds_aitr->second.second & StateAttribute::PROTECTED))
2123 {
2124 // override is on, just treat as a normal apply on uniform.
2125 _lastAppliedProgramObject->apply(*as.uniformVec.back().first);
2126 }
2127 else
2128 {
2129 // no override on or no previous entry, therefore consider incoming attribute.
2130 _lastAppliedProgramObject->apply(*(ds_aitr->second.first.get()));
2131 }
2132
2133 ++this_aitr;
2134 ++ds_aitr;
2135 }
2136 }
2137
2138 // iterator over the remaining state attributes to apply any previous changes.
2139 for(;
2140 this_aitr!=uniformMap.end();
2141 ++this_aitr)
2142 {
2143 // note attribute type = this_aitr->first
2144 UniformStack& as = this_aitr->second;
2145 if (!as.uniformVec.empty())
2146 {
2147 _lastAppliedProgramObject->apply(*as.uniformVec.back().first);
2148 }
2149 }
2150
2151 // iterator over the remaining incoming attribute to apply any new attribute.
2152 for(;
2153 ds_aitr!=uniformList.end();
2154 ++ds_aitr)
2155 {
2156 _lastAppliedProgramObject->apply(*(ds_aitr->second.first.get()));
2157 }
2158
2159}
2160
2161inline void State::applyDefineList(DefineMap& defineMap, const StateSet::DefineList& defineList)
2162{
2163 StateSet::DefineList::const_iterator dl_itr = defineList.begin();
2164 DefineMap::DefineStackMap::iterator dm_itr = defineMap.map.begin();
2165
2166 defineMap.changed = false;
2167 defineMap.currentDefines.clear();
2168
2169 while (dm_itr!=defineMap.map.end() && dl_itr!=defineList.end())
2170 {
2171 if (dm_itr->first<dl_itr->first)
2172 {
2173 DefineStack& ds = dm_itr->second;
2175 if (!dv.empty() && (dv.back().second & StateAttribute::ON)!=0) defineMap.currentDefines[dm_itr->first] = dv.back();
2176
2177 ++dm_itr;
2178 }
2179 else if (dl_itr->first<dm_itr->first)
2180 {
2181 if ((dl_itr->second.second & StateAttribute::ON)!=0) defineMap.currentDefines[dl_itr->first] = dl_itr->second;
2182
2183 ++dl_itr;
2184 }
2185 else
2186 {
2187 // this_mitr & ds_mitr refer to the same mode, check the override
2188 // if any otherwise just apply the incoming mode.
2189
2190 DefineStack& ds = dm_itr->second;
2192
2193 if (!dv.empty() && (dv.back().second & StateAttribute::OVERRIDE)!=0 && !(dl_itr->second.second & StateAttribute::PROTECTED))
2194 {
2195 // override is on, just treat as a normal apply on modes.
2196 if ((dv.back().second & StateAttribute::ON)!=0) defineMap.currentDefines[dm_itr->first] = dv.back();
2197 }
2198 else
2199 {
2200 // no override on or no previous entry, therefore consider incoming mode.
2201 if ((dl_itr->second.second & StateAttribute::ON)!=0) defineMap.currentDefines[dl_itr->first] = dl_itr->second;
2202 }
2203
2204 ++dm_itr;
2205 ++dl_itr;
2206 }
2207 }
2208
2209 // iterator over the remaining state modes to apply any previous changes.
2210 for(;
2211 dm_itr!=defineMap.map.end();
2212 ++dm_itr)
2213 {
2214 // note GLMode = this_mitr->first
2215 DefineStack& ds = dm_itr->second;
2217 if (!dv.empty() && (dv.back().second & StateAttribute::ON)!=0) defineMap.currentDefines[dm_itr->first] = dv.back();
2218 }
2219
2220 // iterator over the remaining incoming modes to apply any new mode.
2221 for(;
2222 dl_itr!=defineList.end();
2223 ++dl_itr)
2224 {
2225 if ((dl_itr->second.second & StateAttribute::ON)!=0) defineMap.currentDefines[dl_itr->first] = dl_itr->second;
2226 }
2227}
2228
2229inline void State::applyModeMap(ModeMap& modeMap)
2230{
2231 for(ModeMap::iterator mitr=modeMap.begin();
2232 mitr!=modeMap.end();
2233 ++mitr)
2234 {
2235 // note GLMode = mitr->first
2236 ModeStack& ms = mitr->second;
2237 if (ms.changed)
2238 {
2239 ms.changed = false;
2240 if (!ms.valueVec.empty())
2241 {
2242 bool new_value = ms.valueVec.back() & StateAttribute::ON;
2243 applyMode(mitr->first,new_value,ms);
2244 }
2245 else
2246 {
2247 // assume default of disabled.
2248 applyMode(mitr->first,ms.global_default_value,ms);
2249 }
2250
2251 }
2252 }
2253}
2254
2255inline void State::applyModeMapOnTexUnit(unsigned int unit,ModeMap& modeMap)
2256{
2257 for(ModeMap::iterator mitr=modeMap.begin();
2258 mitr!=modeMap.end();
2259 ++mitr)
2260 {
2261 // note GLMode = mitr->first
2262 ModeStack& ms = mitr->second;
2263 if (ms.changed)
2264 {
2265 ms.changed = false;
2266 if (!ms.valueVec.empty())
2267 {
2268 bool new_value = ms.valueVec.back() & StateAttribute::ON;
2269 applyModeOnTexUnit(unit,mitr->first,new_value,ms);
2270 }
2271 else
2272 {
2273 // assume default of disabled.
2274 applyModeOnTexUnit(unit,mitr->first,ms.global_default_value,ms);
2275 }
2276
2277 }
2278 }
2279}
2280
2281inline void State::applyAttributeMap(AttributeMap& attributeMap)
2282{
2283 for(AttributeMap::iterator aitr=attributeMap.begin();
2284 aitr!=attributeMap.end();
2285 ++aitr)
2286 {
2287 AttributeStack& as = aitr->second;
2288 if (as.changed)
2289 {
2290 as.changed = false;
2291 if (!as.attributeVec.empty())
2292 {
2293 const StateAttribute* new_attr = as.attributeVec.back().first;
2294 applyAttribute(new_attr,as);
2295 }
2296 else
2297 {
2299 }
2300
2301 }
2302 }
2303}
2304
2305inline void State::applyAttributeMapOnTexUnit(unsigned int unit,AttributeMap& attributeMap)
2306{
2307 for(AttributeMap::iterator aitr=attributeMap.begin();
2308 aitr!=attributeMap.end();
2309 ++aitr)
2310 {
2311 AttributeStack& as = aitr->second;
2312 if (as.changed)
2313 {
2314 as.changed = false;
2315 if (!as.attributeVec.empty())
2316 {
2317 const StateAttribute* new_attr = as.attributeVec.back().first;
2318 applyAttributeOnTexUnit(unit,new_attr,as);
2319 }
2320 else
2321 {
2323 }
2324
2325 }
2326 }
2327}
2328
2329inline void State::applyUniformMap(UniformMap& uniformMap)
2330{
2331 if (!_lastAppliedProgramObject) return;
2332
2333 for(UniformMap::iterator aitr=uniformMap.begin();
2334 aitr!=uniformMap.end();
2335 ++aitr)
2336 {
2337 UniformStack& as = aitr->second;
2338 if (!as.uniformVec.empty())
2339 {
2340 _lastAppliedProgramObject->apply(*as.uniformVec.back().first);
2341 }
2342 }
2343}
2344
2345inline bool State::setActiveTextureUnit( unsigned int unit )
2346{
2347 if (unit!=_currentActiveTextureUnit)
2348 {
2349 if (_glActiveTexture && unit < (unsigned int)(maximum(_glMaxTextureCoords,_glMaxTextureUnits)) )
2350 {
2353 }
2354 else
2355 {
2356 return unit==0;
2357 }
2358 }
2359 return true;
2360}
2361
2362
2363
2364// forward declare speciailization of State::get() method
2365template<> inline GLExtensions* State::get<GLExtensions>() { return _glExtensions.get(); }
2366template<> inline const GLExtensions* State::get<GLExtensions>() const { return _glExtensions.get(); }
2367template<> inline void State::set<GLExtensions>(GLExtensions* ptr) { _glExtensions = ptr; }
2368
2369}
2370
2371#endif
#define GL_TEXTURE0
Definition State:42
#define GL_DRAW_INDIRECT_BUFFER
Definition GLDefines:438
#define GL_PIXEL_UNPACK_BUFFER_ARB
Definition BufferObject:85
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Matrixd Matrix
Definition Matrix:27
T maximum(T lhs, T rhs)
return the maximum of two values, equivalent to std::max.
Definition Math:85
unsigned long long Timer_t
Definition Timer:24
RefMatrixd RefMatrix
Definition Matrix:28
std::set< std::string > ShaderDefines
Definition Shader:37
Definition Array:61
Helper class for managing the dispatch to OpenGL of various attribute arrays such as stored in osg::G...
Definition AttributeDispatchers:35
Definition BufferObject:164
void bindBuffer()
Definition BufferObject:771
bool isDirty() const
Definition BufferObject:222
DisplaySettings class for encapsulating what visuals are required and have been set up,...
Definition DisplaySettings:34
static ref_ptr< DisplaySettings > & instance()
Maintain a DisplaySettings singleton for objects to query at runtime.
Class which encapsulates the frame number, reference time and calendar time of specific frame,...
Definition FrameStamp:35
Definition GLExtensions:135
Main GLExtensions class for managing OpenGL extensions per graphics context.
Definition GLExtensions:160
Base class for providing Windowing API agnostic access to creating and managing graphics context.
Definition GraphicsContext:30
Definition GraphicsCostEstimator:108
virtual StateAttribute * asStateAttribute()
Convert 'this' into a StateAttribute pointer if Object is a StateAttribute, otherwise return 0.
Definition Object:127
const std::string & getName() const
Get the name of object.
Definition Object:213
A Polytope class for representing convex clipping volumes made up of a set of planes.
Definition Polytope:26
osg::Program is an application-level abstraction of an OpenGL glProgram.
Definition Program:52
std::map< std::string, GLuint > AttribBindingList
Definition Program:217
PerContextProgram (PCP) is an OSG-internal encapsulation of glPrograms per-GL context.
Definition Program:264
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Base class for providing reference counted objects.
Definition Referenced:44
Definition Shader:318
deprecated
Definition ShaderComposer:30
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
unsigned int getContextID() const
Get the current OpenGL context unique ID.
Definition State:114
GLBufferObject * _currentDIBO
Definition State:1306
void releaseGLObjects()
Release all OpenGL objects associated cached by this osg::State object.
unsigned int getMaxBufferObjectPoolSize() const
Definition State:901
const TextureModeMapList & getTextureModeMapList() const
Definition State:1074
virtual void frameCompleted()
called by the GraphicsContext just before GraphicsContext::swapBuffersImplementation().
DefineMap & getDefineMap()
Definition State:1072
bool getLastAppliedMode(StateAttribute::GLMode mode) const
Get whether the current specified mode is enabled (true) or disabled (false).
void applyAttributeMap(AttributeMap &attributeMap)
Definition State:2281
void setCheckForGLErrors(CheckForGLErrors check)
Set whether and how often OpenGL errors should be checked for.
Definition State:920
FrameStamp * getFrameStamp()
Get the frame stamp for the current frame.
Definition State:830
void setContextID(unsigned int contextID)
Set the current OpenGL context uniqueID.
Definition State:111
bool checkGLErrors(const StateAttribute *attribute) const
GraphicsContext * getGraphicsContext()
Get the graphics context associated with that owns this State object.
Definition State:90
void VerteAttrib(unsigned int location, float x, float y=0.0f, float z=0.0f, float w=0.0f)
Definition State:715
AttributeMap _attributeMap
Definition State:1288
void setVertexPointer(const Array *array)
Set the vertex pointer using an osg::Array, and manage any VBO that are required.
Definition State:727
AttributeDispatchers & getAttributeDispatchers()
Get the helper class for dispatching osg::Arrays as OpenGL attribute data.
Definition State:936
DrawElementsInstancedProc _glDrawElementsInstanced
Definition State:1398
void setGraphicsCostEstimator(GraphicsCostEstimator *gce)
Set the helper class that provides applications with estimate on how much different graphics operatio...
Definition State:940
void setCurrentPixelBufferObject(osg::GLBufferObject *pbo)
Definition State:580
void applyModeList(ModeMap &modeMap, const StateSet::ModeList &modeList)
Definition State:1607
bool _useModelViewAndProjectionUniforms
Definition State:1108
void(GL_APIENTRY * MultiTexCoord4fProc)(GLenum target, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
Definition State:1368
void(GL_APIENTRY * DrawArraysInstancedProc)(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
Definition State:1378
bool applyAttributeOnTexUnit(unsigned int unit, const StateAttribute *attribute, AttributeStack &as)
Definition State:1207
Matrix _initialInverseViewMatrix
Definition State:1114
void pushDefineList(DefineMap &defineMap, const StateSet::DefineList &defineList)
Definition State:1500
IndicesGLushort _quadIndicesGLushort[4]
Definition State:641
void setColorAlias(const VertexAttribAlias &alias)
Set the vertex attribute aliasing for "color".
Definition State:272
void popDefineList(DefineMap &uniformMap, const StateSet::DefineList &defineList)
Definition State:1585
bool _isVertexBufferObjectSupported
Definition State:1360
BindBufferProc _glBindBuffer
Definition State:1396
const osg::Matrix & getProjectionMatrix() const
Definition State:232
bool useVertexBufferObject(bool useVBO) const
Definition State:790
std::vector< ref_ptr< const Matrix > > MatrixStack
Definition State:1067
VertexAttribPointerProc _glVertexAttribPointer
Definition State:1391
void applyShaderCompositionUniform(const osg::Uniform *uniform, StateAttribute::OverrideValue value=StateAttribute::ON)
Convenience method for StateAttribute::apply(State&) methods to pass on their uniforms to osg::State ...
Definition State:174
void unbindDrawIndirectBufferObject()
Definition State:623
void applyModelViewAndProjectionUniformsIfRequired()
bool applyMode(StateAttribute::GLMode mode, bool enabled, ModeStack &ms)
Apply an OpenGL mode if required, passing in mode, enable flag and appropriate mode stack.
Definition State:1143
const StateAttribute * getLastAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0) const
Get the current specified texture attribute, return NULL if one has not yet been applied.
void disableFogCoordPointer()
Definition State:746
std::string getDefineString(const osg::ShaderDefines &shaderDefines)
void setGlobalDefaultAttribute(const StateAttribute *attribute)
Definition State:431
void applyUniformMap(UniformMap &uniformMap)
Definition State:2329
void resetCurrentVertexArrayStateOnMatch(VertexArrayState *vas)
Reset the CurrentVertexArrayState/VertexArrayObject if it's value matches the specificied vas - use w...
Definition State:553
void setNormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE)
Definition State:733
void(GL_APIENTRY * VertexAttribPointerProc)(unsigned int, GLint, GLenum, GLboolean normalized, GLsizei stride, const GLvoid *pointer)
Definition State:1371
T * get()
Get a specific GL extensions object or GraphicsObjectManager, initialize if not already present.
Definition State:124
VertexAttribAlias _colorAlias
Definition State:1125
void(GL_APIENTRY * VertexAttribIPointerProc)(unsigned int, GLint, GLenum, GLsizei stride, const GLvoid *pointer)
Definition State:1372
void popModeList(ModeMap &modeMap, const StateSet::ModeList &modeList)
Definition State:1538
void decrementDynamicObjectCount()
Decrement the number of dynamic objects left to render this frame, and once the count goes to zero ca...
Definition State:888
bool _shaderCompositionDirty
Definition State:1092
ShaderComposer * getShaderComposer()
deprecated.
Definition State:165
bool getUseVertexAttributeAliasing() const
Definition State:256
void setLastAppliedProgramObject(const Program::PerContextProgram *program)
Definition State:796
bool getGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode)
Definition State:409
const VertexAttribAlias & getNormalAlias()
Definition State:269
void glReadBuffer(GLenum buffer)
void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
texture Mode has been set externally, update state to reflect this setting.
void haveAppliedMode(StateAttribute::GLMode mode)
Mode has been set externally, therefore dirty the associated mode in osg::State so it is applied on n...
void setTexCoordPointer(unsigned int unit, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE)
Definition State:750
void setCurrentToGlobalVertexArrayState()
Set the getCurrentVertexArrayState to the GlobalVertexArrayState.
Definition State:550
GLenum getDrawBuffer() const
Definition State:308
void setMaxTexturePoolSize(unsigned int size)
void setVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE)
Definition State:728
void(GL_APIENTRY * EnableVertexAttribProc)(unsigned int)
Definition State:1374
int _timestampBits
Definition State:1412
ActiveTextureProc _glActiveTexture
Definition State:1385
AttributeMap & getOrCreateTextureAttributeMap(unsigned int unit)
Definition State:1317
void setVertexAttribLPointer(unsigned int unit, const Array *array)
Definition State:778
void setCurrentVertexArrayObject(GLuint vao)
Definition State:630
ref_ptr< const RefMatrix > _projection
Definition State:1104
const GraphicsContext * getGraphicsContext() const
Get the const graphics context associated with that owns this State object.
Definition State:93
int getTimestampBits() const
Definition State:969
void(GL_APIENTRY * VertexAttribLPointerProc)(unsigned int, GLint, GLenum, GLsizei stride, const GLvoid *pointer)
Definition State:1373
DisplaySettings * getActiveDisplaySettings()
Get the DisplaySettings that is current active DisplaySettings to be used by osg::State,...
Definition State:845
bool getModeValidity(StateAttribute::GLMode mode)
Get whether a particular OpenGL mode is valid in the current graphics context.
Definition State:324
void applyUniformList(UniformMap &uniformMap, const StateSet::UniformList &uniformList)
Definition State:2087
void applyModelViewMatrix(const osg::Matrix &)
const StateAttribute * getLastAppliedAttribute(StateAttribute::Type type, unsigned int member=0) const
Get the current specified attribute, return NULL if one has not yet been applied.
void setGlobalDefaultTextureAttribute(unsigned int unit, const StateAttribute *attribute)
Definition State:451
const GLBufferObject * getCurrentVertexBufferObject()
Definition State:568
void haveAppliedAttribute(AttributeMap &attributeMap, const StateAttribute *attribute)
bool getGlobalDefaultModeValue(StateAttribute::GLMode mode)
Definition State:336
VertexAttrib4fvProc _glVertexAttrib4fv
Definition State:1388
CheckForGLErrors getCheckForGLErrors() const
Get whether and how often OpenGL errors should be checked for.
Definition State:923
const TextureAttributeMapList & getTextureAttributeMapList() const
Definition State:1075
void applyModelViewMatrix(const osg::RefMatrix *matrix)
osg::ref_ptr< GLExtensions > _glExtensions
Definition State:1400
void insertStateSet(unsigned int pos, const StateSet *dstate)
Insert stateset onto state stack.
bool getAbortRendering() const
Get flag for early termination of the draw traversal, if true steps should be taken to complete rende...
Definition State:856
bool getLastAppliedTextureModeValue(unsigned int unit, StateAttribute::GLMode mode)
Definition State:424
unsigned int getActiveTextureUnit() const
Get the current texture unit.
Definition State:767
const Program::PerContextProgram * getLastAppliedProgramObject() const
Definition State:803
DefineMap _defineMap
Definition State:1290
ref_ptr< const RefMatrix > _identity
Definition State:1102
void bindVertexArrayObject(GLuint vao)
Definition State:635
bool _isVertexArrayObjectSupported
Definition State:1361
void setColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_TRUE)
Definition State:737
const osg::Matrix & getModelViewMatrix() const
Definition State:237
void setUpVertexAttribAlias(VertexAttribAlias &alias, GLuint location, const std::string glName, const std::string osgName, const std::string &declaration)
void(GL_APIENTRY * VertexAttrib4fvProc)(GLuint index, const GLfloat *v)
Definition State:1370
void setGlobalDefaultTextureModeValue(unsigned int unit, StateAttribute::GLMode mode, bool enabled)
Definition State:402
bool _useVertexAttributeAliasing
Definition State:1122
void(GL_APIENTRY * DrawElementsInstancedProc)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
Definition State:1379
void haveAppliedTextureAttribute(unsigned int unit, const StateAttribute *attribute)
texture Attribute has been applied externally, update state to reflect this setting.
void popStateSet()
Pop stateset off state stack.
void applyAttributeListOnTexUnit(unsigned int unit, AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
Definition State:1969
void Normal(float x, float y, float z)
Definition State:681
void(GL_APIENTRY * DisableVertexAttribProc)(unsigned int)
Definition State:1375
std::vector< ModeMap > TextureModeMapList
Definition State:1059
bool * _abortRenderingPtr
Definition State:1118
Polytope getViewFrustum() const
std::vector< VertexAttribAlias > VertexAttribAliasList
Definition State:258
bool checkGLErrors(StateAttribute::GLMode mode) const
void lazyDisablingOfVertexAttributes()
Definition State:564
bool setClientActiveTextureUnit(unsigned int unit)
Set the current tex coord array texture unit, return true if selected, false if selection failed such...
void setAbortRenderingPtr(bool *abortPtr)
Set flag for early termination of the draw traversal.
Definition State:852
AttributeVec & getAttributeVec(const osg::StateAttribute *attribute)
Definition State:820
void applyShaderComposition()
Apply any shader composed state.
osg::ref_ptr< ShaderComposer > _shaderComposer
Definition State:1093
void disableVertexAttribPointer(unsigned int index)
Definition State:781
bool getLastAppliedMode(const ModeMap &modeMap, StateAttribute::GLMode mode) const
VertexAttribAlias _secondaryColorAlias
Definition State:1126
bool _shaderCompositionEnabled
Definition State:1091
ref_ptr< RefMatrix > _modelViewCache
Definition State:1106
GLint getAttribLocation(const std::string &name) const
Definition State:815
void popAttributeList(AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
Definition State:1554
void setTimestampBits(int bits)
Definition State:970
osg::Uniform * getModelViewMatrixUniform()
Definition State:246
const StateAttribute * getGlobalDefaultTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0)
Definition State:458
bool supportsShaderRequirement(const std::string &shaderRequirement)
void popAllStateSets()
pop all statesets off state stack, ensuring it is empty ready for the next frame.
void TexCoord(float x, float y=0.0f, float z=0.0f, float w=1.0f)
Definition State:691
void setVertexAttribIPointer(unsigned int unit, const Array *array)
Definition State:779
void bindPixelBufferObject(osg::GLBufferObject *pbo)
Definition State:583
osg::Uniform * getNormalMatrixUniform()
Definition State:249
void haveAppliedAttribute(AttributeMap &attributeMap, StateAttribute::Type type, unsigned int member)
Program::AttribBindingList _attributeBindingList
Definition State:1130
std::pair< const StateAttribute *, StateAttribute::OverrideValue > AttributePair
Definition State:817
void applyAttributeMapOnTexUnit(unsigned int unit, AttributeMap &attributeMap)
Definition State:2305
void popStateSetStackToSize(unsigned int size)
Pop StateSet's for the StateSet stack till its size equals the specified size.
Definition State:202
StateSetStack _stateStateStack
Definition State:1297
GLint _glMaxTextureUnits
Definition State:1383
void removeStateSet(unsigned int pos)
Pop stateset off state stack.
void dirtyAllVertexArrays()
dirty the vertex, normal, color, tex coords, secondary color, fog coord and index arrays.
GLBufferObject * _currentPBO
Definition State:1305
ref_ptr< Uniform > _modelViewProjectionMatrixUniform
Definition State:1111
Timer_t _gpuTick
Definition State:1410
bool applyGlobalDefaultAttributeOnTexUnit(unsigned int unit, AttributeStack &as)
Definition State:1260
void reset()
reset the state object to an empty stack.
StateSet::UniformList & getCurrentShaderCompositionUniformList()
Get the unform list in which to inject any uniforms that StateAttribute::apply(State&) methods provid...
Definition State:171
VertexAttribAlias _fogCoordAlias
Definition State:1127
EnableVertexAttribProc _glEnableVertexAttribArray
Definition State:1394
ref_ptr< const RefMatrix > _modelView
Definition State:1105
GLint getMaxTextureUnits() const
For GL>=2.0 uses GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, for GL<2 uses GL_MAX_TEXTURE_UNITS.
Definition State:758
ModeMap & getOrCreateTextureModeMap(unsigned int unit)
Definition State:1310
void setVertexAlias(const VertexAttribAlias &alias)
Set the vertex attribute aliasing for "vertex".
Definition State:264
void unbindVertexBufferObject()
Definition State:571
void glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
Definition State:648
TextureAttributeMapList _textureAttributeMapList
Definition State:1293
void setTexCoordPointer(unsigned int unit, const Array *array)
Definition State:749
const GLBufferObject * getCurrentElementBufferObject()
Definition State:574
void setCurrentVertexArrayState(VertexArrayState *vas)
Set the CurrentVetexArrayState object that take which vertex arrays are bound.
Definition State:544
Timer_t getGpuTick() const
Definition State:956
void popUniformList(UniformMap &uniformMap, const StateSet::UniformList &uniformList)
Definition State:1570
const osg::Matrix & getInitialInverseViewMatrix() const
Definition State:228
void unbindElementBufferObject()
Definition State:577
void haveAppliedAttribute(StateAttribute::Type type, unsigned int member=0)
Attribute has been applied externally, and therefore this attribute type has been dirtied and will ne...
bool supportsShaderRequirements(const osg::ShaderDefines &shaderRequirements)
void haveAppliedMode(ModeMap &modeMap, StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
void applyModeMap(ModeMap &modeMap)
Definition State:2229
FogCoordPointerProc _glFogCoordPointer
Definition State:1389
std::vector< GLushort > IndicesGLushort
Definition State:640
ActiveTextureProc _glClientActiveTexture
Definition State:1384
void unbindPixelBufferObject()
Definition State:600
void loadModelViewMatrix()
void disableVertexAttribPointersAboveAndIncluding(unsigned int index)
Definition State:782
IndicesGLuint _quadIndicesGLuint[4]
Definition State:644
void updateModelViewAndProjectionMatrixUniforms()
void setAttributeBindingList(const Program::AttribBindingList &attribBindingList)
Set the vertex attribute binding list.
Definition State:288
GLenum getReadBuffer() const
Definition State:311
void pushUniformList(UniformMap &uniformMap, const StateSet::UniformList &uniformList)
Definition State:1472
Timer_t getStartTick() const
Support for synchronizing the system time and the timestamp counter available with ARB_timer_query.
Definition State:954
void(GL_APIENTRY * SecondaryColorPointerProc)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
Definition State:1367
void setGraphicsContext(GraphicsContext *context)
Set the graphics context associated with that owns this State object.
Definition State:87
ref_ptr< Uniform > _projectionMatrixUniform
Definition State:1110
const Program::PerContextProgram * _lastAppliedProgramObject
Definition State:1295
VertexAttribAlias _vertexAlias
Definition State:1123
void bindVertexBufferObject(osg::GLBufferObject *vbo)
Definition State:570
const StateAttribute * getLastAppliedAttribute(const AttributeMap &attributeMap, StateAttribute::Type type, unsigned int member) const
GLuint64 getGpuTimestamp() const
Definition State:962
void haveAppliedAttribute(const StateAttribute *attribute)
Attribute has been applied externally, update state to reflect this setting.
void(GL_APIENTRY * VertexAttrib4fProc)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
Definition State:1369
bool getUseModelViewAndProjectionUniforms() const
Definition State:240
void MultiTexCoord(unsigned int unit, float x, float y=0.0f, float z=0.0f, float w=1.0f)
Definition State:703
ref_ptr< FrameStamp > _frameStamp
Definition State:1097
std::vector< GLuint > IndicesGLuint
Definition State:643
void setColorPointer(const Array *array)
Definition State:736
bool applyAttribute(const StateAttribute *attribute, AttributeStack &as)
apply an attribute if required, passing in attribute and appropriate attribute stack
Definition State:1183
const DisplaySettings * getDisplaySettings() const
Get the const DisplaySettings.
Definition State:842
VertexAttribAliasList _texCoordAliasList
Definition State:1128
void applyModeMapOnTexUnit(unsigned int unit, ModeMap &modeMap)
Definition State:2255
void pushAttributeList(AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
Definition State:1442
bool isVertexBufferObjectSupported() const
Definition State:789
void disableAllVertexArrays()
disable the vertex, normal, color, tex coords, secondary color, fog coord and index arrays.
GLenum _readBuffer
Definition State:1100
void setShaderCompositionEnabled(bool flag)
Definition State:156
GLint getUniformLocation(unsigned int uniformNameID) const
Definition State:805
void setFrameStamp(FrameStamp *fs)
Set the frame stamp for the current frame.
Definition State:827
std::map< StateAttribute::TypeMemberPair, AttributeStack > AttributeMap
Definition State:1061
unsigned int getMaxTexturePoolSize() const
Definition State:898
const Program::AttribBindingList & getAttributeBindingList()
Definition State:289
void haveAppliedMode(ModeMap &modeMap, StateAttribute::GLMode mode)
void captureCurrentState(StateSet &stateset) const
Copy the modes and attributes which capture the current state.
void setVertexAttribPointer(unsigned int unit, const Array *array)
Definition State:777
DisableVertexAttribProc _glDisableVertexAttribArray
Definition State:1395
ref_ptr< const RefMatrix > _initialViewMatrix
Definition State:1103
void dirtyAllAttributes()
Dirty the modes attributes previously applied in osg::State.
const DisplaySettings * getActiveDisplaySettings() const
Get the const DisplaySettings that is current active DisplaySettings to be used by osg::State,...
Definition State:848
GraphicsContext * _graphicsContext
Definition State:1085
VertexArrayState * getCurrentVertexArrayState() const
Get the CurrentVetexArrayState object that take which vertex arrays are bound.
Definition State:547
GLint getUniformLocation(const std::string &uniformName) const
Alternative version of getUniformLocation( unsigned int uniformNameID ) retrofited into OSG for backw...
Definition State:814
Timer_t _startTick
Definition State:1409
void setTexCoordAliasList(const VertexAttribAliasList &aliasList)
Set the vertex attribute aliasing list for texture coordinates.
Definition State:284
unsigned int _contextID
Definition State:1086
SecondaryColorPointerProc _glSecondaryColorPointer
Definition State:1390
void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode)
texture Mode has been set externally, therefore dirty the associated mode in osg::State so it is appl...
GLint _glMaxTextureCoords
Definition State:1382
void disableSecondaryColorPointer()
Definition State:742
bool useVertexArrayObject(bool useVAO) const
Definition State:793
std::vector< const StateSet * > StateSetStack
Definition State:204
bool _isFogCoordSupported
Definition State:1359
std::map< StateAttribute::GLMode, ModeStack > ModeMap
Definition State:1058
ref_ptr< Uniform > _modelViewMatrixUniform
Definition State:1109
std::map< const std::type_info *, osg::ref_ptr< osg::Referenced > > ExtensionMap
Definition State:118
void setInitialViewMatrix(const osg::RefMatrix *matrix)
void print(std::ostream &fout) const
print out the internal details of osg::State - useful for debugging.
unsigned int getStateSetStackSize()
Get the number of StateSet's on the StateSet stack.
Definition State:199
ref_ptr< DisplaySettings > _displaySettings
Definition State:1116
ModeMap _modeMap
Definition State:1287
void unbindVertexArrayObject()
Definition State:637
virtual ~State()
UniformMap _uniformMap
Definition State:1289
void apply(const StateSet *dstate)
Apply stateset.
unsigned int getClientActiveTextureUnit() const
Get the current tex coord array texture unit.
const UniformMap & getUniformMap() const
Definition State:1071
void haveAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0)
texture Attribute has been applied externally, and therefore this attribute type has been dirtied and...
void(GL_APIENTRY * BindBufferProc)(GLenum target, GLuint buffer)
Definition State:1376
const ShaderComposer * getShaderComposer() const
deprecated.
Definition State:168
void set(T *ptr)
Set a specific GL extensions object pr GraphicsObjectManager.
Definition State:149
const GLBufferObject * getCurrentPixelBufferObject() const
Definition State:581
std::map< std::string, UniformStack > UniformMap
Definition State:1064
CheckForGLErrors
Definition State:905
@ ONCE_PER_ATTRIBUTE
ONCE_PER_ATTRIBUTE means that OpenGL errors will be checked for after every attribute is applied,...
Definition State:916
@ NEVER_CHECK_GL_ERRORS
NEVER_CHECK_GL_ERRORS hints that OpenGL need not be checked for, this is the fastest option since che...
Definition State:908
@ ONCE_PER_FRAME
ONCE_PER_FRAME means that OpenGL errors will be checked for once per frame, the overhead is still sma...
Definition State:912
const VertexAttribAliasList & getTexCoordAliasList()
Definition State:285
void pushStateSet(const StateSet *dstate)
Push stateset onto state stack.
void setNormalPointer(const Array *array)
Definition State:732
void setGlobalDefaultModeValue(StateAttribute::GLMode mode, bool enabled)
Definition State:330
void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
Definition State:654
const GraphicsCostEstimator * getGraphicsCostEstimator() const
Get the cont helper class that provides applications with estimate on how much different graphics ope...
Definition State:946
bool _forceVertexBufferObject
Definition State:1362
VertexAttrib4fProc _glVertexAttrib4f
Definition State:1387
void setStartTick(Timer_t tick)
Definition State:955
void applyModeListOnTexUnit(unsigned int unit, ModeMap &modeMap, const StateSet::ModeList &modeList)
Definition State:1729
DrawArraysInstancedProc _glDrawArraysInstanced
Definition State:1397
osg::ref_ptr< GraphicsCostEstimator > _graphicsCostEstimator
Definition State:1407
CheckForGLErrors _checkGLErrors
Definition State:1119
void apply()
Updates the OpenGL state so that it matches the StateSet at the top of the stack of StateSets maintai...
TextureModeMapList _textureModeMapList
Definition State:1292
const FrameStamp * getFrameStamp() const
Get the const frame stamp for the current frame.
Definition State:833
void setModeValidity(StateAttribute::GLMode mode, bool valid)
Set whether a particular OpenGL mode is valid in the current graphics context.
Definition State:316
void(GL_APIENTRY * ActiveTextureProc)(GLenum texture)
Definition State:1365
osg::Uniform * getProjectionMatrixUniform()
Definition State:247
GLuint64 _gpuTimestamp
Definition State:1411
unsigned int _dynamicObjectCount
Definition State:1402
void setCurrentElementBufferObject(osg::GLBufferObject *ebo)
Definition State:573
osg::ref_ptr< VertexArrayState > _globalVertexArrayState
Definition State:1088
std::vector< AttributeMap > TextureAttributeMapList
Definition State:1062
const DefineMap & getDefineMap() const
Definition State:1073
GLenum _drawBuffer
Definition State:1099
void disableColorPointer()
Definition State:738
VertexArrayState * _vas
Definition State:1089
void setSecondaryColorAlias(const VertexAttribAlias &alias)
Set the vertex attribute aliasing for "secondary color".
Definition State:276
bool _isSecondaryColorSupported
Definition State:1358
GLuint _currentVAO
Definition State:1307
AttributeDispatchers _arrayDispatchers
Definition State:1405
void setFogCoordPointer(const Array *array)
Definition State:745
bool applyGlobalDefaultAttribute(AttributeStack &as)
Definition State:1237
StateSetStack & getStateSetStack()
Get the StateSet stack.
Definition State:207
void setDisplaySettings(DisplaySettings *vs)
Set the DisplaySettings.
Definition State:839
bool getShaderCompositionEnabled() const
Definition State:159
bool getLastAppliedModeValue(StateAttribute::GLMode mode)
Definition State:341
bool getLastAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode) const
Get whether the current specified texture mode is enabled (true) or disabled (false).
void Color(float r, float g, float b, float a=1.0f)
Definition State:671
bool applyModeOnTexUnit(unsigned int unit, StateAttribute::GLMode mode, bool enabled, ModeStack &ms)
Definition State:1160
bool _extensionProcsInitialized
Definition State:1381
bool _forceVertexArrayObject
Definition State:1363
unsigned int _maxBufferObjectPoolSize
Definition State:1300
void setMaxBufferObjectPoolSize(unsigned int size)
void applyAttributeList(AttributeMap &attributeMap, const StateSet::AttributeList &attributeList)
Definition State:1851
void disableTexCoordPointersAboveAndIncluding(unsigned int unit)
Definition State:752
GraphicsCostEstimator * getGraphicsCostEstimator()
Get the helper class that provides applications with estimate on how much different graphics operatio...
Definition State:943
ref_ptr< Uniform > _normalMatrixUniform
Definition State:1112
void bindDrawIndirectBufferObject(osg::GLBufferObject *ibo)
Definition State:609
const VertexAttribAlias & getVertexAlias()
Definition State:265
const VertexAttribAlias & getSecondaryColorAlias()
Definition State:277
GLuint getCurrentVertexArrayObject() const
Definition State:631
const T * get() const
Get a specific GL extensions object or GraphicsObjectManager if it already exists in the extension ma...
Definition State:139
void dirtyAllModes()
Dirty the modes previously applied in osg::State.
void haveAppliedMode(StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
Mode has been set externally, update state to reflect this setting.
bool applyTextureAttribute(unsigned int unit, const StateAttribute *attribute)
Definition State:466
unsigned int _currentClientActiveTextureUnit
Definition State:1304
osg::Program * _currentShaderCompositionProgram
Definition State:1094
VertexAttribIPointerProc _glVertexAttribIPointer
Definition State:1392
void disableTexCoordPointer(unsigned int unit)
Definition State:751
void drawQuads(GLint first, GLsizei count, GLsizei primCount=0)
const Viewport * getCurrentViewport() const
Definition State:219
bool isFogCoordSupported() const
Definition State:744
void Vertex(float x, float y, float z, float w=1.0f)
Definition State:661
bool applyMode(StateAttribute::GLMode mode, bool enabled)
Apply an OpenGL mode if required.
Definition State:395
bool isSecondaryColorSupported() const
Definition State:740
void setSecondaryColorPointer(const Array *array)
Definition State:741
const ModeMap & getModeMap() const
Definition State:1069
ExtensionMap _extensionMap
Definition State:119
unsigned int getDynamicObjectCount() const
Get the number of dynamic objects that will be rendered in this graphics context this frame.
Definition State:884
std::vector< AttributePair > AttributeVec
Definition State:818
VertexAttribAlias _normalAlias
Definition State:1124
void setFogCoordAlias(const VertexAttribAlias &alias)
Set the vertex attribute aliasing for "fog coord".
Definition State:280
void setUseModelViewAndProjectionUniforms(bool flag)
Definition State:239
bool applyAttribute(const StateAttribute *attribute)
Apply an attribute if required.
Definition State:444
const VertexAttribAlias & getFogCoordAlias()
Definition State:281
void disableVertexPointer()
Definition State:729
void applyProjectionMatrix(const osg::RefMatrix *matrix)
osg::ref_ptr< DynamicObjectRenderingCompletedCallback > _completeDynamicObjectRenderingCallback
Definition State:1403
DynamicObjectRenderingCompletedCallback * getDynamicObjectRenderingCompletedCallback()
Get the callback to be called when the dynamic object count hits 0.
Definition State:868
void disableNormalPointer()
Definition State:734
void applyDefineList(DefineMap &uniformMap, const StateSet::DefineList &defineList)
Definition State:2161
bool setActiveTextureUnit(unsigned int unit)
Set the current texture unit, return true if selected, false if selection failed such as when multi t...
Definition State:2345
void(GL_APIENTRY * FogCoordPointerProc)(GLenum type, GLsizei stride, const GLvoid *pointer)
Definition State:1366
void pushModeList(ModeMap &modeMap, const StateSet::ModeList &modeList)
Definition State:1415
const StateAttribute * getGlobalDefaultAttribute(StateAttribute::Type type, unsigned int member=0)
Definition State:437
void setShaderComposer(ShaderComposer *sc)
deprecated.
Definition State:162
osg::Uniform * getModelViewProjectionMatrixUniform()
Definition State:248
void setGpuTimestamp(Timer_t tick, GLuint64 timestamp)
Definition State:964
void setCurrentVertexBufferObject(osg::GLBufferObject *vbo)
Definition State:567
bool isVertexArrayObjectSupported() const
Definition State:792
bool applyTextureMode(unsigned int unit, StateAttribute::GLMode mode, bool enabled)
Definition State:416
const osg::Matrix & getInitialViewMatrix() const
Definition State:227
unsigned int _currentActiveTextureUnit
Definition State:1303
VertexAttribLPointerProc _glVertexAttribLPointer
Definition State:1393
void setDynamicObjectRenderingCompletedCallback(DynamicObjectRenderingCompletedCallback *cb)
Set the callback to be called when the dynamic object count hits 0.
Definition State:865
const VertexAttribAlias & getColorAlias()
Definition State:273
double getGpuTime() const
Definition State:958
const AttributeMap & getAttributeMap() const
Definition State:1070
void initializeExtensionProcs()
Initialize extension used by osg::State.
MultiTexCoord4fProc _glMultiTexCoord4f
Definition State:1386
StateSet::UniformList _currentShaderCompositionUniformList
Definition State:1095
void bindVertexArrayObject(const VertexArrayState *vas)
Definition State:633
GLint getMaxTextureCoords() const
For GL>=2.0 uses GL_MAX_TEXTURE_COORDS, for GL<2 uses GL_MAX_TEXTURE_UNITS.
Definition State:755
void setDynamicObjectCount(unsigned int count, bool callCallbackOnZero=false)
Set the number of dynamic objects that will be rendered in this graphics context this frame.
Definition State:871
void applyDisablingOfVertexAttributes()
Definition State:565
unsigned int _maxTexturePoolSize
Definition State:1299
void setNormalAlias(const VertexAttribAlias &alias)
Set the vertex attribute aliasing for "normal".
Definition State:268
void setUseVertexAttributeAliasing(bool flag)
void resetVertexAttributeAlias(bool compactAliasing=true, unsigned int numTextureUnits=8)
Reset the vertex attribute aliasing to osg's default.
bool checkGLErrors(const char *str1=0, const char *str2=0) const
void glDrawBuffer(GLenum buffer)
void bindElementBufferObject(osg::GLBufferObject *ebo)
Definition State:576
bool convertVertexShaderSourceToOsgBuiltIns(std::string &source) const
void setInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
Wrapper around glInterleavedArrays(..).
Definition State:724
~ApplyModeProxy()
Definition State:355
ApplyModeProxy(osg::State &state, GLenum mode, bool value)
Definition State:349
bool _need_to_apply_value
Definition State:363
osg::State & _state
Definition State:360
GLenum _mode
Definition State:361
bool _previous_value
Definition State:362
bool _previous_value
Definition State:382
osg::State & _state
Definition State:379
GLenum _mode
Definition State:381
bool _need_to_apply_value
Definition State:383
ApplyTextureModeProxy(osg::State &state, unsigned int unit, GLenum mode, bool value)
Definition State:368
~ApplyTextureModeProxy()
Definition State:374
unsigned int _unit
Definition State:380
~SetCurrentVertexArrayStateProxy()
Definition State:539
SetCurrentVertexArrayStateProxy(osg::State &state, VertexArrayState *vas)
Definition State:538
osg::State & _state
Definition State:540
Definition State:977
bool valid
Definition State:990
std::vector< StateAttribute::GLModeValue > ValueVec
Definition State:978
bool changed
Definition State:991
ValueVec valueVec
Definition State:994
bool global_default_value
Definition State:993
bool last_applied_value
Definition State:992
void print(std::ostream &fout) const
ModeStack()
Definition State:980
Definition State:998
const ShaderComponent * last_applied_shadercomponent
Definition State:1013
AttributeStack()
Definition State:999
bool changed
apply an attribute if required, passing in attribute and appropriate attribute stack
Definition State:1011
AttributeVec attributeVec
Definition State:1015
const StateAttribute * last_applied_attribute
Definition State:1012
void print(std::ostream &fout) const
ref_ptr< const StateAttribute > global_default_attribute
Definition State:1014
Definition State:1020
UniformVec uniformVec
Definition State:1028
UniformStack()
Definition State:1024
std::vector< UniformPair > UniformVec
Definition State:1022
std::pair< const Uniform *, StateAttribute::OverrideValue > UniformPair
Definition State:1021
void print(std::ostream &fout) const
Definition State:1032
DefineStack()
Definition State:1035
void print(std::ostream &fout) const
std::vector< StateSet::DefinePair > DefineVec
Definition State:1033
DefineVec defineVec
Definition State:1041
bool changed
Definition State:1040
Definition State:1045
bool changed
Definition State:1051
std::map< std::string, DefineStack > DefineStackMap
Definition State:1049
DefineStackMap map
Definition State:1050
StateSet::DefineList currentDefines
Definition State:1052
DefineMap()
Definition State:1046
Base class for state attributes.
Definition StateAttribute:77
GLenum GLMode
GLMode is the value used in glEnable/glDisable(mode)
Definition StateAttribute:81
@ OVERRIDE
Overriding of GLMode's or StateAttributes is enabled, so that state below it is overridden.
Definition StateAttribute:105
@ PROTECTED
Protecting of GLMode's or StateAttributes is enabled, so that state from above cannot override this a...
Definition StateAttribute:107
@ ON
means that associated GLMode is enabled and Override is disabled.
Definition StateAttribute:103
ShaderComponent * getShaderComponent()
Definition StateAttribute:304
TypeMemberPair getTypeMemberPair() const
Return the TypeMemberPair that uniquely identifies this type member.
Definition StateAttribute:270
unsigned int GLModeValue
GLModeValue is used to specify whether a mode is enabled (ON) or disabled (OFF).
Definition StateAttribute:85
virtual void apply(State &) const
apply the OpenGL state attributes.
Definition StateAttribute:358
Type
Type identifier to differentiate between different state types.
Definition StateAttribute:124
@ VIEWPORT
Definition StateAttribute:155
std::pair< Type, unsigned int > TypeMemberPair
Simple pairing between an attribute type and the member within that attribute type group.
Definition StateAttribute:218
virtual Object * cloneType() const =0
Clone the type of an attribute, with Object* return type.
unsigned int OverrideValue
Override is used to specify the override behavior of StateAttributes from parent to children.
Definition StateAttribute:89
Stores a set of modes and attributes which represent a set of OpenGL state.
Definition StateSet:46
std::pair< ref_ptr< Uniform >, StateAttribute::OverrideValue > RefUniformPair
Simple pairing between a Uniform and its override flag.
Definition StateSet:302
std::map< std::string, RefUniformPair > UniformList
a container to map Uniform name to its respective RefUniformPair.
Definition StateSet:305
std::map< StateAttribute::TypeMemberPair, RefAttributePair > AttributeList
a container to map <StateAttribyte::Types,Member> to their respective RefAttributePair.
Definition StateSet:166
std::pair< std::string, StateAttribute::OverrideValue > DefinePair
Definition StateSet:345
std::map< StateAttribute::GLMode, StateAttribute::GLModeValue > ModeList
a container to map GLModes to their respective GLModeValues.
Definition StateSet:119
std::map< std::string, DefinePair > DefineList
Definition StateSet:346
static Timer * instance()
double delta_s(Timer_t t1, Timer_t t2) const
Get the time in seconds between timer ticks t1 and t2.
Definition Timer:59
Uniform encapsulates glUniform values.
Definition Uniform:414
Definition VertexArrayState:25
GLuint getVertexArrayObject() const
Definition VertexArrayState:173
Encapsulate OpenGL glViewport.
Definition Viewport:24
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.