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
This commit is contained in:
Robert Osfield
2016-08-12 18:44:38 +01:00
parent d8fdf33be5
commit 94891778c4
10 changed files with 175 additions and 116 deletions

View File

@@ -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> _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