Moved implementations from .cpp's to headers as inline methods to improve performance.

This commit is contained in:
Robert Osfield
2016-08-04 22:00:58 +01:00
parent 97df15b205
commit 1f147f6bc6
7 changed files with 448 additions and 396 deletions

View File

@@ -256,11 +256,7 @@ class OSG_EXPORT Drawable : public Node
* \c virtual). Subclasses should override
* \c drawImplementation() instead.
*/
#if 0
inline void draw(RenderInfo& renderInfo) const;
#else
void draw(RenderInfo& renderInfo) const;
#endif
inline void drawInner(RenderInfo& renderInfo) const
{
@@ -495,7 +491,76 @@ class OSG_EXPORT Drawable : public Node
ref_ptr<DrawCallback> _drawCallback;
};
#if 0
#if 1
inline void Drawable::draw(RenderInfo& renderInfo) const
{
State& state = *renderInfo.getState();
bool useVertexArrayObject = _useVertexBufferObjects && state.useVertexArrayObject();
if (useVertexArrayObject)
{
unsigned int contextID = renderInfo.getContextID();
VertexArrayState* vas = _vertexArrayStateList[contextID].get();
if (!vas)
{
_vertexArrayStateList[contextID] = vas = createVertexArrayState(renderInfo, true);
}
else
{
// vas->setRequiresSetArrays(getDataVariance()==osg::Object::DYNAMIC);
}
State::SetCurrentVertexArrayStateProxy setVASProxy(state, vas);
vas->bindVertexArrayObject();
drawInner(renderInfo);
vas->setRequiresSetArrays(getDataVariance()==osg::Object::DYNAMIC);
return;
}
// TODO, add check against whether VOA is active and supported
if (state.getCurrentVertexArrayState()) state.getCurrentVertexArrayState()->bindVertexArrayObject();
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
if (_useDisplayList)
{
// 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 );
drawInner(renderInfo);
glEndList();
}
// call the display list
glCallList( globj);
}
else
#endif
{
// if state.previousVertexArrayState() is different than currentVertexArrayState bind current
// OSG_NOTICE<<"Fallback drawInner()........................"<<std::endl;
drawInner(renderInfo);
}
}
#else
inline void Drawable::draw(RenderInfo& renderInfo) const
{
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE