Implemented lighter weight setting of the CurrentVertexArrayState and introduced GlobalVertexArrayState.

This commit is contained in:
Robert Osfield
2016-07-23 16:33:39 +01:00
parent 7d83d735ad
commit 4b4cd13d31
5 changed files with 21 additions and 14 deletions

View File

@@ -500,12 +500,22 @@ class OSG_EXPORT State : public Referenced
void dirtyAllAttributes();
struct SetCurrentVertexArrayStateProxy
{
SetCurrentVertexArrayStateProxy(osg::State& state, VertexArrayState* vas):_state(state) { _state.setCurrentVertexArrayState(vas); }
~SetCurrentVertexArrayStateProxy() { _state.setCurrentToGloabalVertexArrayState(); }
osg::State& _state;
};
/** Set the CurrentVetexArrayState object that take which vertex arrays are bound.*/
void setCurrentVertexArrayState(VertexArrayState* vas) { _currentVertexArrayState = vas; }
/** Get the CurrentVetexArrayState object that take which vertex arrays are bound.*/
VertexArrayState* getCurrentVertexArrayState() const { return _currentVertexArrayState.get(); }
VertexArrayState* getCurrentVertexArrayState() const { return _currentVertexArrayState; }
/** Set the getCurrentVertexArrayState to the GloabalVertexArrayState.*/
void setCurrentToGloabalVertexArrayState() { _currentVertexArrayState = _globalVertexArrayState.get(); }
/** disable the vertex, normal, color, tex coords, secondary color, fog coord and index arrays.*/
@@ -1780,7 +1790,8 @@ class OSG_EXPORT State : public Referenced
GraphicsContext* _graphicsContext;
unsigned int _contextID;
osg::ref_ptr<VertexArrayState> _currentVertexArrayState;
osg::ref_ptr<VertexArrayState> _globalVertexArrayState;
VertexArrayState* _currentVertexArrayState;
bool _shaderCompositionEnabled;
bool _shaderCompositionDirty;

View File

@@ -153,7 +153,7 @@ public:
public:
osg::GLBufferObject* getGLBufferObject(osg::Array* array);
// osg::GLBufferObject* getGLBufferObject(osg::Array* array);
osg::ref_ptr<osg::GLExtensions> _ext;