Added Geometry::drawVertexArraysomplemetation(..) and drawPrimitivesImplemenation(..) methods that are called from drawImplementation(..). These new vertex methods
allow subclasses from osg::Geometry to specialize the vertex array setup or how the primitives are dispatched to OpenGL.
This commit is contained in:
parent
dbf88cc209
commit
a54b999ccc
@ -173,6 +173,12 @@ class OSG_EXPORT Geometry : public Drawable
|
|||||||
*/
|
*/
|
||||||
virtual void drawImplementation(RenderInfo& renderInfo) const;
|
virtual void drawImplementation(RenderInfo& renderInfo) const;
|
||||||
|
|
||||||
|
/** Set up the vertex arrays for the purpose of rendering, called by drawImplemtation() prior to it calling drawPrimitivesImplementation().*/
|
||||||
|
void drawVertexArraysImplementation(RenderInfo& renderInfo) const;
|
||||||
|
|
||||||
|
/** dispatch the primitives to OpenGL, called by drawImplemtation() after calling drawVertexArraysImplementation().*/
|
||||||
|
void drawPrimitivesImplementation(RenderInfo& renderInfo) const;
|
||||||
|
|
||||||
/** Return true, osg::Geometry does support accept(Drawable::AttributeFunctor&). */
|
/** Return true, osg::Geometry does support accept(Drawable::AttributeFunctor&). */
|
||||||
virtual bool supports(const Drawable::AttributeFunctor&) const { return true; }
|
virtual bool supports(const Drawable::AttributeFunctor&) const { return true; }
|
||||||
|
|
||||||
|
@ -703,7 +703,27 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
bool checkForGLErrors = state.getCheckForGLErrors()==osg::State::ONCE_PER_ATTRIBUTE;
|
bool checkForGLErrors = state.getCheckForGLErrors()==osg::State::ONCE_PER_ATTRIBUTE;
|
||||||
if (checkForGLErrors) state.checkGLErrors("start of Geometry::drawImplementation()");
|
if (checkForGLErrors) state.checkGLErrors("start of Geometry::drawImplementation()");
|
||||||
|
|
||||||
bool usingVertexBufferObjects = _useVertexBufferObjects && state.isVertexBufferObjectSupported();
|
drawVertexArraysImplementation(renderInfo);
|
||||||
|
|
||||||
|
if (checkForGLErrors) state.checkGLErrors("Geometry::drawImplementation() after vertex arrays setup.");
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// draw the primitives themselves.
|
||||||
|
//
|
||||||
|
drawPrimitivesImplementation(renderInfo);
|
||||||
|
|
||||||
|
// unbind the VBO's if any are used.
|
||||||
|
state.unbindVertexBufferObject();
|
||||||
|
state.unbindElementBufferObject();
|
||||||
|
|
||||||
|
if (checkForGLErrors) state.checkGLErrors("end of Geometry::drawImplementation().");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Geometry::drawVertexArraysImplementation(RenderInfo& renderInfo) const
|
||||||
|
{
|
||||||
|
State& state = *renderInfo.getState();
|
||||||
|
|
||||||
bool handleVertexAttributes = !_vertexAttribList.empty();
|
bool handleVertexAttributes = !_vertexAttribList.empty();
|
||||||
|
|
||||||
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers();
|
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers();
|
||||||
@ -777,15 +797,15 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
state.applyDisablingOfVertexAttributes();
|
state.applyDisablingOfVertexAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Geometry::drawPrimitivesImplementation(RenderInfo& renderInfo) const
|
||||||
|
{
|
||||||
|
State& state = *renderInfo.getState();
|
||||||
|
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers();
|
||||||
|
bool usingVertexBufferObjects = _useVertexBufferObjects && state.isVertexBufferObjectSupported();
|
||||||
|
|
||||||
bool bindPerPrimitiveSetActive = arrayDispatchers.active(osg::Array::BIND_PER_PRIMITIVE_SET);
|
bool bindPerPrimitiveSetActive = arrayDispatchers.active(osg::Array::BIND_PER_PRIMITIVE_SET);
|
||||||
|
|
||||||
if (checkForGLErrors) state.checkGLErrors("Geometry::drawImplementation() after vertex arrays setup.");
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// draw the primitives themselves.
|
|
||||||
//
|
|
||||||
for(unsigned int primitiveSetNum=0; primitiveSetNum!=_primitives.size(); ++primitiveSetNum)
|
for(unsigned int primitiveSetNum=0; primitiveSetNum!=_primitives.size(); ++primitiveSetNum)
|
||||||
{
|
{
|
||||||
// dispatch any attributes that are bound per primitive
|
// dispatch any attributes that are bound per primitive
|
||||||
@ -795,12 +815,6 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
|
|
||||||
primitiveset->draw(state, usingVertexBufferObjects);
|
primitiveset->draw(state, usingVertexBufferObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unbind the VBO's if any are used.
|
|
||||||
state.unbindVertexBufferObject();
|
|
||||||
state.unbindElementBufferObject();
|
|
||||||
|
|
||||||
if (checkForGLErrors) state.checkGLErrors("end of Geometry::drawImplementation().");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AttributeFunctorArrayVisitor : public ArrayVisitor
|
class AttributeFunctorArrayVisitor : public ArrayVisitor
|
||||||
|
Loading…
Reference in New Issue
Block a user