From 94891778c40ff08fcc626f91ded73cda67713b36 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 12 Aug 2016 18:44:38 +0100 Subject: [PATCH] Restructred the enabling of vertex array object support to allow one to set enable the default via osg::State. Added OSG_VERTEX_BUFFER_HINT env var to osg::DisplaySettings with VERTEX_BUFFER_OBJECT/VBO, VERTEX_ARRAY_OBJECT/VAO and NO_PREFERENCE to allow one to foce on VBO or VAO usage. Restructred BufferObject assigned in osg::Geometry Added --- include/osg/DisplaySettings | 12 ++--- include/osg/Drawable | 51 ++++---------------- include/osg/State | 7 +-- include/osg/VertexArrayState | 2 + src/osg/DisplaySettings.cpp | 30 ++++++------ src/osg/Drawable.cpp | 91 ++++++++++++++++++++++++++++++++---- src/osg/Geometry.cpp | 76 +++++++++++++++--------------- src/osg/PrimitiveSet.cpp | 9 ++-- src/osg/State.cpp | 7 ++- src/osg/VertexArrayState.cpp | 6 +++ 10 files changed, 175 insertions(+), 116 deletions(-) diff --git a/include/osg/DisplaySettings b/include/osg/DisplaySettings index 9645b1670..060ec6ec9 100644 --- a/include/osg/DisplaySettings +++ b/include/osg/DisplaySettings @@ -299,15 +299,15 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced int getNvOptimusEnablement() const; - enum GeometryImplementation + enum VertexBufferHint { - OLD_GEOMETRY_IMPLEMENTATION, - NEW_GEOMETRY_IMPLEMENTATION, + NO_PREFERENCE, + VERTEX_BUFFER_OBJECT, VERTEX_ARRAY_OBJECT }; - void setGeometryImplementation(GeometryImplementation gi) { _geometryImplementation = gi; } - GeometryImplementation getGeometryImplementation() const { return _geometryImplementation; } + void setVertexBufferHint(VertexBufferHint gi) { _vertexBufferHint = gi; } + VertexBufferHint getVertexBufferHint() const { return _vertexBufferHint; } void setKeystoneHint(bool enabled) { _keystoneHint = enabled; } @@ -399,7 +399,7 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced SwapMethod _swapMethod; unsigned int _syncSwapBuffers; - GeometryImplementation _geometryImplementation; + VertexBufferHint _vertexBufferHint; bool _keystoneHint; FileNames _keystoneFileNames; diff --git a/include/osg/Drawable b/include/osg/Drawable index 0a2d5700a..0c828e828 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -55,6 +55,8 @@ #endif +#define INLINE_DRAWABLE_DRAW + namespace osg { @@ -256,7 +258,11 @@ class OSG_EXPORT Drawable : public Node * \c virtual). Subclasses should override * \c drawImplementation() instead. */ +#ifdef INLINE_DRAWABLE_DRAW inline void draw(RenderInfo& renderInfo) const; +#else + void draw(RenderInfo& renderInfo) const; +#endif inline void drawInner(RenderInfo& renderInfo) const { @@ -491,12 +497,11 @@ class OSG_EXPORT Drawable : public Node ref_ptr _drawCallback; }; -#if 1 +#ifdef INLINE_DRAWABLE_DRAW inline void Drawable::draw(RenderInfo& renderInfo) const { State& state = *renderInfo.getState(); - bool useVertexArrayObject = _useVertexBufferObjects && state.useVertexArrayObject(); - + bool useVertexArrayObject = state.useVertexArrayObject(_useVertexArrayObject); if (useVertexArrayObject) { unsigned int contextID = renderInfo.getContextID(); @@ -560,46 +565,6 @@ inline void Drawable::draw(RenderInfo& renderInfo) const drawInner(renderInfo); } } -#else -inline void Drawable::draw(RenderInfo& renderInfo) const -{ -#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE - if (_useDisplayList && !(_supportsVertexBufferObjects && _useVertexBufferObjects && renderInfo.getState()->isVertexBufferObjectSupported())) - { - // get the contextID (user defined ID of 0 upwards) for the - // current OpenGL context. - unsigned int contextID = renderInfo.getContextID(); - - // get the globj for the current contextID. - GLuint& globj = _globjList[contextID]; - - if( globj == 0 ) - { - // compile the display list - globj = generateDisplayList(contextID, getGLObjectSizeHint()); - glNewList( globj, GL_COMPILE ); - - if (_drawCallback.valid()) - _drawCallback->drawImplementation(renderInfo,this); - else - drawImplementation(renderInfo); - - glEndList(); - } - - // call the display list - glCallList( globj); - - return; - } -#endif - - // draw object as nature intended.. - if (_drawCallback.valid()) - _drawCallback->drawImplementation(renderInfo,this); - else - drawImplementation(renderInfo); -} #endif class AttributeFunctorArrayVisitor : public ArrayVisitor diff --git a/include/osg/State b/include/osg/State index 570cac5aa..7bb302137 100644 --- a/include/osg/State +++ b/include/osg/State @@ -716,10 +716,11 @@ class OSG_EXPORT State : public Referenced inline bool isVertexBufferObjectSupported() const { return _isVertexBufferObjectSupported; } + inline bool useVertexBufferObject(bool useVBO) const { return _forceVertexBufferObject || (_isVertexBufferObjectSupported && useVBO); } inline bool isVertexArrayObjectSupported() const { return _isVertexArrayObjectSupported; } + inline bool useVertexArrayObject(bool useVAO) const { return _forceVertexArrayObject || (_isVertexArrayObjectSupported && useVAO); } - inline bool useVertexArrayObject() const { return _useVertexArrayObject; } inline void setLastAppliedProgramObject(const Program::PerContextProgram* program) { @@ -1306,8 +1307,8 @@ class OSG_EXPORT State : public Referenced bool _isFogCoordSupported; bool _isVertexBufferObjectSupported; bool _isVertexArrayObjectSupported; - - bool _useVertexArrayObject; + bool _forceVertexBufferObject; + bool _forceVertexArrayObject; typedef void (GL_APIENTRY * ActiveTextureProc) (GLenum texture); typedef void (GL_APIENTRY * FogCoordPointerProc) (GLenum type, GLsizei stride, const GLvoid *pointer); diff --git a/include/osg/VertexArrayState b/include/osg/VertexArrayState index 62085b224..bd09b5fc5 100644 --- a/include/osg/VertexArrayState +++ b/include/osg/VertexArrayState @@ -161,6 +161,8 @@ public: void setRequiresSetArrays(bool flag) { _requiresSetArrays = flag; } bool getRequiresSetArrays() const { return _requiresSetArrays; } + void dirty(); + void release(); public: diff --git a/src/osg/DisplaySettings.cpp b/src/osg/DisplaySettings.cpp index 128ed9ca8..0aadd67dd 100644 --- a/src/osg/DisplaySettings.cpp +++ b/src/osg/DisplaySettings.cpp @@ -116,7 +116,7 @@ void DisplaySettings::setDisplaySettings(const DisplaySettings& vs) _glContextProfileMask = vs._glContextProfileMask; _swapMethod = vs._swapMethod; - _geometryImplementation = vs._geometryImplementation; + _vertexBufferHint = vs._vertexBufferHint; _keystoneHint = vs._keystoneHint; _keystoneFileNames = vs._keystoneFileNames; @@ -243,8 +243,9 @@ void DisplaySettings::setDefaults() _swapMethod = SWAP_DEFAULT; _syncSwapBuffers = 0; - // _geometryImplementation = VERTEX_ARRAY_OBJECT; - _geometryImplementation = OLD_GEOMETRY_IMPLEMENTATION; + _vertexBufferHint = NO_PREFERENCE; + // _vertexBufferHint = VERTEX_BUFFER_OBJECT; + // _vertexBufferHint = VERTEX_ARRAY_OBJECT; _keystoneHint = false; @@ -367,8 +368,8 @@ static ApplicationUsageProxy DisplaySetting_e31(ApplicationUsage::ENVIRONMENTAL_ "OSG_NvOptimusEnablement ", "Set the hint to NvOptimus of whether to enable it or not, set 1 to enable, 0 to disable"); static ApplicationUsageProxy DisplaySetting_e32(ApplicationUsage::ENVIRONMENTAL_VARIABLE, - "OSG_GEOMETRY_IMPLEMENTATION ", - "Set the hint to what backend osg::Geometry implementation to use. OLD | NEW | VERTEX_ARRAY_OBJECT"); + "OSG_VERTEX_BUFFER_HINT ", + "Set the hint to what backend osg::Geometry implementation to use. NO_PREFERENCE | VERTEX_BUFFER_OBJECT | VERTEX_ARRAY_OBJECT"); void DisplaySettings::readEnvironmentalVariables() { @@ -680,19 +681,22 @@ void DisplaySettings::readEnvironmentalVariables() } - if ((ptr = getenv("OSG_GEOMETRY_IMPLEMENTATION")) != 0) + if ((ptr = getenv("OSG_VERTEX_BUFFER_HINT")) != 0) { - if (strcmp(ptr,"OLD")==0) + if (strcmp(ptr,"VERTEX_BUFFER_OBJECT")==0 || strcmp(ptr,"VBO")==0) { - _geometryImplementation = OLD_GEOMETRY_IMPLEMENTATION; - } - else if (strcmp(ptr,"NEW")==0 ) - { - _geometryImplementation = NEW_GEOMETRY_IMPLEMENTATION; + OSG_NOTICE<<"OSG_VERTEX_BUFFER_HINT set to VERTEX_BUFFER_OBJECT"<release(); - _vertexArrayStateList[i] = 0; - } + if (vas) vas->dirty(); } } @@ -624,7 +620,86 @@ void Drawable::compileGLObjects(RenderInfo& renderInfo) const #endif } +#ifndef INLINE_DRAWABLE_DRAW + +void Drawable::draw(RenderInfo& renderInfo) const +{ + // OSG_NOTICE<<"Geometry::draw() "<assignAllDispatchers(); + return vos; } diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index b320e6e67..c690fcb7a 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -70,7 +70,7 @@ Geometry::Geometry(const Geometry& geometry,const CopyOp& copyop): if ((copyop.getCopyFlags() & osg::CopyOp::DEEP_COPY_ARRAYS) || (copyop.getCopyFlags() & osg::CopyOp::DEEP_COPY_PRIMITIVES)) { - if (_useVertexBufferObjects) + /*if (_useVertexBufferObjects)*/ { // copying of arrays doesn't set up buffer objects so we'll need to force // Geometry to assign these, we'll do this by changing the cached value to false then re-enabling. @@ -114,7 +114,7 @@ void Geometry::setVertexArray(Array* array) dirtyDisplayList(); dirtyBound(); - if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array); + if (/*_useVertexBufferObjects && */array) addVertexBufferObjectIfRequired(array); } void Geometry::setNormalArray(Array* array, osg::Array::Binding binding) @@ -125,7 +125,7 @@ void Geometry::setNormalArray(Array* array, osg::Array::Binding binding) dirtyDisplayList(); - if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array); + if (/*_useVertexBufferObjects && */array) addVertexBufferObjectIfRequired(array); } void Geometry::setColorArray(Array* array, osg::Array::Binding binding) @@ -136,7 +136,7 @@ void Geometry::setColorArray(Array* array, osg::Array::Binding binding) dirtyDisplayList(); - if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array); + if (/*_useVertexBufferObjects && */array) addVertexBufferObjectIfRequired(array); } void Geometry::setSecondaryColorArray(Array* array, osg::Array::Binding binding) @@ -147,7 +147,7 @@ void Geometry::setSecondaryColorArray(Array* array, osg::Array::Binding binding) dirtyDisplayList(); - if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array); + if (/*_useVertexBufferObjects && */array) addVertexBufferObjectIfRequired(array); } void Geometry::setFogCoordArray(Array* array, osg::Array::Binding binding) @@ -158,7 +158,7 @@ void Geometry::setFogCoordArray(Array* array, osg::Array::Binding binding) dirtyDisplayList(); - if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array); + if (/*_useVertexBufferObjects && */array) addVertexBufferObjectIfRequired(array); } @@ -178,7 +178,7 @@ void Geometry::setTexCoordArray(unsigned int index,Array* array, osg::Array::Bin dirtyDisplayList(); - if (_useVertexBufferObjects && array) + if (/*_useVertexBufferObjects && */array) { addVertexBufferObjectIfRequired(array); } @@ -202,7 +202,7 @@ void Geometry::setTexCoordArrayList(const ArrayList& arrayList) dirtyDisplayList(); - if (_useVertexBufferObjects) + /*if (_useVertexBufferObjects)*/ { for(ArrayList::iterator itr = _texCoordList.begin(); itr != _texCoordList.end(); @@ -224,7 +224,7 @@ void Geometry::setVertexAttribArray(unsigned int index, Array* array, osg::Array dirtyDisplayList(); - if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array); + if (/*_useVertexBufferObjects && */array) addVertexBufferObjectIfRequired(array); } Array *Geometry::getVertexAttribArray(unsigned int index) @@ -245,7 +245,7 @@ void Geometry::setVertexAttribArrayList(const ArrayList& arrayList) dirtyDisplayList(); - if (_useVertexBufferObjects) + /*if (_useVertexBufferObjects)*/ { for(ArrayList::iterator itr = _vertexAttribList.begin(); itr != _vertexAttribList.end(); @@ -261,7 +261,7 @@ bool Geometry::addPrimitiveSet(PrimitiveSet* primitiveset) { if (primitiveset) { - if (_useVertexBufferObjects) addElementBufferObjectIfRequired(primitiveset); + /*if (_useVertexBufferObjects)*/ addElementBufferObjectIfRequired(primitiveset); _primitives.push_back(primitiveset); dirtyDisplayList(); @@ -277,7 +277,7 @@ bool Geometry::setPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset) { if (i<_primitives.size() && primitiveset) { - if (_useVertexBufferObjects) addElementBufferObjectIfRequired(primitiveset); + /*if (_useVertexBufferObjects)*/ addElementBufferObjectIfRequired(primitiveset); _primitives[i] = primitiveset; dirtyDisplayList(); @@ -293,7 +293,7 @@ bool Geometry::insertPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset) if (primitiveset) { - if (_useVertexBufferObjects) addElementBufferObjectIfRequired(primitiveset); + /*if (_useVertexBufferObjects)*/ addElementBufferObjectIfRequired(primitiveset); if (i<_primitives.size()) { @@ -315,7 +315,7 @@ bool Geometry::insertPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset) void Geometry::setPrimitiveSetList(const PrimitiveSetList& primitives) { _primitives = primitives; - if (_useVertexBufferObjects) + /*if (_useVertexBufferObjects)*/ { for (unsigned int primitiveSetIndex=0;primitiveSetIndex<_primitives.size();++primitiveSetIndex) { @@ -451,7 +451,7 @@ bool Geometry::getDrawElementsList(DrawElementsList& drawElementsList) const void Geometry::addVertexBufferObjectIfRequired(osg::Array* array) { - if (_useVertexBufferObjects) + /*if (_useVertexBufferObjects)*/ { if (!array->getVertexBufferObject()) { @@ -462,7 +462,7 @@ void Geometry::addVertexBufferObjectIfRequired(osg::Array* array) void Geometry::addElementBufferObjectIfRequired(osg::PrimitiveSet* primitiveSet) { - if (_useVertexBufferObjects) + /*if (_useVertexBufferObjects)*/ { osg::DrawElements* drawElements = primitiveSet->getDrawElements(); if (drawElements && !drawElements->getElementBufferObject()) @@ -525,7 +525,7 @@ void Geometry::setUseVertexBufferObjects(bool flag) typedef std::vector VertexBufferObjectList; typedef std::vector ElementBufferObjectList; - if (_useVertexBufferObjects) + /*if (_useVertexBufferObjects)*/ { if (!arrayList.empty()) { @@ -580,6 +580,7 @@ void Geometry::setUseVertexBufferObjects(bool flag) } } } + /* else { for(ArrayList::iterator vitr = arrayList.begin(); @@ -598,6 +599,7 @@ void Geometry::setUseVertexBufferObjects(bool flag) if (elements->getElementBufferObject()) elements->setElementBufferObject(0); } } + */ } void Geometry::dirtyGLObjects() @@ -636,7 +638,14 @@ void Geometry::releaseGLObjects(State* state) const { Drawable::releaseGLObjects(state); - if (state) _vertexArrayStateList[state->getContextID()]; + if (state) + { + if (_vertexArrayStateList[state->getContextID()].valid()) + { + _vertexArrayStateList[state->getContextID()]->release(); + _vertexArrayStateList[state->getContextID()] = 0; + } + } else _vertexArrayStateList.clear(); ArrayList arrays; @@ -665,13 +674,11 @@ void Geometry::releaseGLObjects(State* state) const VertexArrayState* Geometry::createVertexArrayState(RenderInfo& renderInfo, bool usingVBOs) const { - OSG_NOTICE<<"Creating new osg::VertexArrayState"<assignVertexArrayDispatcher(); if (_colorArray.valid()) vas->assignColorArrayDispatcher(); @@ -682,15 +689,15 @@ VertexArrayState* Geometry::createVertexArrayState(RenderInfo& renderInfo, bool if (!_texCoordList.empty()) vas->assignTexCoordArrayDispatcher(_texCoordList.size()); if (!_vertexAttribList.empty()) vas->assignVertexAttribArrayDispatcher(_vertexAttribList.size()); - if (usingVBOs && ds->getGeometryImplementation()==DisplaySettings::VERTEX_ARRAY_OBJECT) + if (state.useVertexArrayObject(_useVertexArrayObject)) { - OSG_NOTICE<<" Setup VertexArrayState to use VAO"<generateVertexArrayObject(); } else { - OSG_NOTICE<<" Setup VertexArrayState to without using VAO"<isVertexBufferObjectSupported(); - if (useVertexArrays) + if (renderInfo.getState()->useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects)) { unsigned int contextID = state.getContextID(); GLExtensions* extensions = state.get(); @@ -760,7 +764,7 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0); - if (state.useVertexArrayObject() && !bufferObjects.empty()) + if (state.useVertexArrayObject(_useVertexArrayObject) && !bufferObjects.empty()) { VertexArrayState* vas = 0; @@ -806,9 +810,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const drawPrimitivesImplementation(renderInfo); - bool useVertexArrayObject = _useVertexBufferObjects && state.useVertexArrayObject(); - unsigned int contextID = renderInfo.getContextID(); - if (!useVertexArrayObject || _vertexArrayStateList[contextID]->getRequiresSetArrays()) + if (!state.useVertexArrayObject(_useVertexArrayObject) || state.getCurrentVertexArrayState()->getRequiresSetArrays()) { // unbind the VBO's if any are used. state.unbindVertexBufferObject(); @@ -846,11 +848,9 @@ void Geometry::drawVertexArraysImplementation(RenderInfo& renderInfo) const arrayDispatchers.dispatch(osg::Array::BIND_OVERALL,0); - bool useVertexArrayObject = _useVertexBufferObjects && state.useVertexArrayObject(); - unsigned int contextID = renderInfo.getContextID(); - if (useVertexArrayObject) + if (state.useVertexArrayObject(_useVertexArrayObject)) { - if (!_vertexArrayStateList[contextID]->getRequiresSetArrays()) return; + if (!state.getCurrentVertexArrayState()->getRequiresSetArrays()) return; } state.lazyDisablingOfVertexAttributes(); @@ -909,7 +909,7 @@ void Geometry::drawPrimitivesImplementation(RenderInfo& renderInfo) const { State& state = *renderInfo.getState(); ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers(); - bool usingVertexBufferObjects = _useVertexBufferObjects && state.isVertexBufferObjectSupported(); + bool usingVertexBufferObjects = state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects); bool bindPerPrimitiveSetActive = arrayDispatchers.active(osg::Array::BIND_PER_PRIMITIVE_SET); for(unsigned int primitiveSetNum=0; primitiveSetNum!=_primitives.size(); ++primitiveSetNum) diff --git a/src/osg/PrimitiveSet.cpp b/src/osg/PrimitiveSet.cpp index a654d5a92..987192906 100644 --- a/src/osg/PrimitiveSet.cpp +++ b/src/osg/PrimitiveSet.cpp @@ -196,15 +196,16 @@ void DrawElementsUByte::draw(State& state, bool useVertexBufferObjects) const if (useVertexBufferObjects) { GLBufferObject* ebo = getOrCreateGLBufferObject(state.getContextID()); - state.getCurrentVertexArrayState()->bindElementBufferObject(ebo); if (ebo) { + state.getCurrentVertexArrayState()->bindElementBufferObject(ebo); if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_BYTE, (const GLvoid *)(ebo->getOffset(getBufferIndex())), _numInstances); else glDrawElements(mode, size(), GL_UNSIGNED_BYTE, (const GLvoid *)(ebo->getOffset(getBufferIndex()))); } else { + state.getCurrentVertexArrayState()->unbindElementBufferObject(); if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_BYTE, &front(), _numInstances); else glDrawElements(mode, size(), GL_UNSIGNED_BYTE, &front()); } @@ -257,15 +258,16 @@ void DrawElementsUShort::draw(State& state, bool useVertexBufferObjects) const if (useVertexBufferObjects) { GLBufferObject* ebo = getOrCreateGLBufferObject(state.getContextID()); - state.getCurrentVertexArrayState()->bindElementBufferObject(ebo); if (ebo) { + state.getCurrentVertexArrayState()->bindElementBufferObject(ebo); if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_SHORT, (const GLvoid *)(ebo->getOffset(getBufferIndex())), _numInstances); else glDrawElements(mode, size(), GL_UNSIGNED_SHORT, (const GLvoid *)(ebo->getOffset(getBufferIndex()))); } else { + state.getCurrentVertexArrayState()->unbindElementBufferObject(); if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_SHORT, &front(), _numInstances); else glDrawElements(mode, size(), GL_UNSIGNED_SHORT, &front()); } @@ -317,15 +319,16 @@ void DrawElementsUInt::draw(State& state, bool useVertexBufferObjects) const if (useVertexBufferObjects) { GLBufferObject* ebo = getOrCreateGLBufferObject(state.getContextID()); - state.getCurrentVertexArrayState()->bindElementBufferObject(ebo); if (ebo) { + state.getCurrentVertexArrayState()->bindElementBufferObject(ebo); if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_INT, (const GLvoid *)(ebo->getOffset(getBufferIndex())), _numInstances); else glDrawElements(mode, size(), GL_UNSIGNED_INT, (const GLvoid *)(ebo->getOffset(getBufferIndex()))); } else { + state.getCurrentVertexArrayState()->unbindElementBufferObject(); if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_INT, &front(), _numInstances); else glDrawElements(mode, size(), GL_UNSIGNED_INT, &front()); } diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 73f84c097..0ce9f2fae 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -96,7 +96,9 @@ State::State(): _isFogCoordSupported = false; _isVertexBufferObjectSupported = false; _isVertexArrayObjectSupported = false; - _useVertexArrayObject = false; + + _forceVertexBufferObject = false; + _forceVertexArrayObject = false; _lastAppliedProgramObject = 0; @@ -176,7 +178,8 @@ void State::initializeExtensionProcs() _isVertexArrayObjectSupported = _glExtensions->isVAOSupported; const DisplaySettings* ds = getDisplaySettings() ? getDisplaySettings() : osg::DisplaySettings::instance(); - _useVertexArrayObject = _isVertexArrayObjectSupported && (ds->getGeometryImplementation()==DisplaySettings::VERTEX_ARRAY_OBJECT); + _forceVertexArrayObject = _isVertexArrayObjectSupported && (ds->getVertexBufferHint()==DisplaySettings::VERTEX_ARRAY_OBJECT); + _forceVertexBufferObject = _forceVertexArrayObject || (_isVertexBufferObjectSupported && (ds->getVertexBufferHint()==DisplaySettings::VERTEX_BUFFER_OBJECT)); // Set up up global VertexArrayState object diff --git a/src/osg/VertexArrayState.cpp b/src/osg/VertexArrayState.cpp index 7d09839b5..075127248 100644 --- a/src/osg/VertexArrayState.cpp +++ b/src/osg/VertexArrayState.cpp @@ -719,3 +719,9 @@ void VertexArrayState::setInterleavedArrays( osg::State& state, GLenum format, G dirtyAllVertexArrays(); #endif } + +void VertexArrayState::dirty() +{ + setRequiresSetArrays(true); +} +