Renamed ArrayDispatchers to AttributeDispatchers to better reflect it's role

This commit is contained in:
Robert Osfield 2016-10-11 15:14:14 +01:00
parent e14ee80282
commit 38ff11f8c5
7 changed files with 40 additions and 40 deletions

View File

@ -11,8 +11,8 @@
* OpenSceneGraph Public License for more details. * OpenSceneGraph Public License for more details.
*/ */
#ifndef OSG_ArrayDispatchers #ifndef OSG_ATTRIBUTEDISPATCHERS
#define OSG_ArrayDispatchers 1 #define OSG_ATTRIBUTEDISPATCHERS 1
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <osg/Array> #include <osg/Array>
@ -31,12 +31,12 @@ struct AttributeDispatch : public osg::Referenced
}; };
/** Helper class for managing the dispatch to OpenGL of various attribute arrays such as stored in osg::Geometry.*/ /** Helper class for managing the dispatch to OpenGL of various attribute arrays such as stored in osg::Geometry.*/
class OSG_EXPORT ArrayDispatchers : public osg::Referenced class OSG_EXPORT AttributeDispatchers : public osg::Referenced
{ {
public: public:
ArrayDispatchers(); AttributeDispatchers();
~ArrayDispatchers(); ~AttributeDispatchers();
void setState(osg::State* state); void setState(osg::State* state);

View File

@ -29,7 +29,7 @@
#include <osg/DisplaySettings> #include <osg/DisplaySettings>
#include <osg/Polytope> #include <osg/Polytope>
#include <osg/Viewport> #include <osg/Viewport>
#include <osg/ArrayDispatchers> #include <osg/AttributeDispatchers>
#include <osg/GraphicsCostEstimator> #include <osg/GraphicsCostEstimator>
#include <iosfwd> #include <iosfwd>
@ -877,7 +877,7 @@ class OSG_EXPORT State : public Referenced
void initializeExtensionProcs(); void initializeExtensionProcs();
/** Get the helper class for dispatching osg::Arrays as OpenGL attribute data.*/ /** Get the helper class for dispatching osg::Arrays as OpenGL attribute data.*/
inline ArrayDispatchers& getArrayDispatchers() { return _arrayDispatchers; } inline AttributeDispatchers& getAttributeDispatchers() { return _arrayDispatchers; }
/** Set the helper class that provides applications with estimate on how much different graphics operations will cost.*/ /** Set the helper class that provides applications with estimate on how much different graphics operations will cost.*/
@ -1341,7 +1341,7 @@ class OSG_EXPORT State : public Referenced
unsigned int _dynamicObjectCount; unsigned int _dynamicObjectCount;
osg::ref_ptr<DynamicObjectRenderingCompletedCallback> _completeDynamicObjectRenderingCallback; osg::ref_ptr<DynamicObjectRenderingCompletedCallback> _completeDynamicObjectRenderingCallback;
ArrayDispatchers _arrayDispatchers; AttributeDispatchers _arrayDispatchers;
osg::ref_ptr<GraphicsCostEstimator> _graphicsCostEstimator; osg::ref_ptr<GraphicsCostEstimator> _graphicsCostEstimator;

View File

@ -17,7 +17,7 @@
#include <osg/Referenced> #include <osg/Referenced>
#include <osg/GLExtensions> #include <osg/GLExtensions>
#include <osg/Array> #include <osg/Array>
#include <osg/ArrayDispatchers> #include <osg/AttributeDispatchers>
namespace osg { namespace osg {

View File

@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details. * OpenSceneGraph Public License for more details.
*/ */
#include <osg/ArrayDispatchers> #include <osg/AttributeDispatchers>
#include <osg/State> #include <osg/State>
#include <osg/Drawable> #include <osg/Drawable>
@ -141,7 +141,7 @@ public:
AttributeDispatchList _attributeDispatchList; AttributeDispatchList _attributeDispatchList;
}; };
ArrayDispatchers::ArrayDispatchers(): AttributeDispatchers::AttributeDispatchers():
_initialized(false), _initialized(false),
_state(0), _state(0),
_normalDispatchers(0), _normalDispatchers(0),
@ -153,7 +153,7 @@ ArrayDispatchers::ArrayDispatchers():
} }
ArrayDispatchers::~ArrayDispatchers() AttributeDispatchers::~AttributeDispatchers()
{ {
delete _normalDispatchers; delete _normalDispatchers;
delete _colorDispatchers; delete _colorDispatchers;
@ -168,12 +168,12 @@ ArrayDispatchers::~ArrayDispatchers()
} }
} }
void ArrayDispatchers::setState(osg::State* state) void AttributeDispatchers::setState(osg::State* state)
{ {
_state = state; _state = state;
} }
void ArrayDispatchers::init() void AttributeDispatchers::init()
{ {
if (_initialized) return; if (_initialized) return;
@ -213,41 +213,41 @@ void ArrayDispatchers::init()
// With inidices // With inidices
// //
AttributeDispatch* ArrayDispatchers::normalDispatcher(Array* array) AttributeDispatch* AttributeDispatchers::normalDispatcher(Array* array)
{ {
return _useVertexAttribAlias ? return _useVertexAttribAlias ?
vertexAttribDispatcher(_state->getNormalAlias()._location, array) : vertexAttribDispatcher(_state->getNormalAlias()._location, array) :
_normalDispatchers->dispatcher(array); _normalDispatchers->dispatcher(array);
} }
AttributeDispatch* ArrayDispatchers::colorDispatcher(Array* array) AttributeDispatch* AttributeDispatchers::colorDispatcher(Array* array)
{ {
return _useVertexAttribAlias ? return _useVertexAttribAlias ?
vertexAttribDispatcher(_state->getColorAlias()._location, array) : vertexAttribDispatcher(_state->getColorAlias()._location, array) :
_colorDispatchers->dispatcher(array); _colorDispatchers->dispatcher(array);
} }
AttributeDispatch* ArrayDispatchers::secondaryColorDispatcher(Array* array) AttributeDispatch* AttributeDispatchers::secondaryColorDispatcher(Array* array)
{ {
return _useVertexAttribAlias ? return _useVertexAttribAlias ?
vertexAttribDispatcher(_state->getSecondaryColorAlias()._location, array) : vertexAttribDispatcher(_state->getSecondaryColorAlias()._location, array) :
_secondaryColorDispatchers->dispatcher(array); _secondaryColorDispatchers->dispatcher(array);
} }
AttributeDispatch* ArrayDispatchers::fogCoordDispatcher(Array* array) AttributeDispatch* AttributeDispatchers::fogCoordDispatcher(Array* array)
{ {
return _useVertexAttribAlias ? return _useVertexAttribAlias ?
vertexAttribDispatcher(_state->getFogCoordAlias()._location, array) : vertexAttribDispatcher(_state->getFogCoordAlias()._location, array) :
_fogCoordDispatchers->dispatcher(array); _fogCoordDispatchers->dispatcher(array);
} }
AttributeDispatch* ArrayDispatchers::vertexAttribDispatcher(unsigned int unit, Array* array) AttributeDispatch* AttributeDispatchers::vertexAttribDispatcher(unsigned int unit, Array* array)
{ {
if (unit>=_vertexAttribDispatchers.size()) assignVertexAttribDispatchers(unit); if (unit>=_vertexAttribDispatchers.size()) assignVertexAttribDispatchers(unit);
return _vertexAttribDispatchers[unit]->dispatcher(array); return _vertexAttribDispatchers[unit]->dispatcher(array);
} }
void ArrayDispatchers::assignVertexAttribDispatchers(unsigned int unit) void AttributeDispatchers::assignVertexAttribDispatchers(unsigned int unit)
{ {
GLExtensions* extensions = _state->get<GLExtensions>(); GLExtensions* extensions = _state->get<GLExtensions>();
@ -262,7 +262,7 @@ void ArrayDispatchers::assignVertexAttribDispatchers(unsigned int unit)
} }
} }
void ArrayDispatchers::reset() void AttributeDispatchers::reset()
{ {
if (!_initialized) init(); if (!_initialized) init();

View File

@ -24,7 +24,7 @@ SET(TARGET_H
${HEADER_PATH}/ApplicationUsage ${HEADER_PATH}/ApplicationUsage
${HEADER_PATH}/ArgumentParser ${HEADER_PATH}/ArgumentParser
${HEADER_PATH}/Array ${HEADER_PATH}/Array
${HEADER_PATH}/ArrayDispatchers ${HEADER_PATH}/AttributeDispatchers
${HEADER_PATH}/AudioStream ${HEADER_PATH}/AudioStream
${HEADER_PATH}/AutoTransform ${HEADER_PATH}/AutoTransform
${HEADER_PATH}/Billboard ${HEADER_PATH}/Billboard
@ -239,7 +239,7 @@ SET(TARGET_SRC
ApplicationUsage.cpp ApplicationUsage.cpp
ArgumentParser.cpp ArgumentParser.cpp
Array.cpp Array.cpp
ArrayDispatchers.cpp AttributeDispatchers.cpp
AudioStream.cpp AudioStream.cpp
AutoTransform.cpp AutoTransform.cpp
Billboard.cpp Billboard.cpp

View File

@ -13,7 +13,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <osg/Geometry> #include <osg/Geometry>
#include <osg/ArrayDispatchers> #include <osg/AttributeDispatchers>
#include <osg/VertexArrayState> #include <osg/VertexArrayState>
#include <osg/Notify> #include <osg/Notify>
@ -827,24 +827,24 @@ void Geometry::drawVertexArraysImplementation(RenderInfo& renderInfo) const
bool handleVertexAttributes = !_vertexAttribList.empty(); bool handleVertexAttributes = !_vertexAttribList.empty();
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers(); AttributeDispatchers& attributeDispatchers = state.getAttributeDispatchers();
arrayDispatchers.reset(); attributeDispatchers.reset();
arrayDispatchers.setUseVertexAttribAlias(state.getUseVertexAttributeAliasing()); attributeDispatchers.setUseVertexAttribAlias(state.getUseVertexAttributeAliasing());
if (handleVertexAttributes) if (handleVertexAttributes)
{ {
for(unsigned int unit=0;unit<_vertexAttribList.size();++unit) for(unsigned int unit=0;unit<_vertexAttribList.size();++unit)
{ {
arrayDispatchers.activateVertexAttribArray(unit, _vertexAttribList[unit].get()); attributeDispatchers.activateVertexAttribArray(unit, _vertexAttribList[unit].get());
} }
} }
// activate or dispatch any attributes that are bound overall // activate or dispatch any attributes that are bound overall
arrayDispatchers.activateNormalArray(_normalArray.get()); attributeDispatchers.activateNormalArray(_normalArray.get());
arrayDispatchers.activateColorArray(_colorArray.get()); attributeDispatchers.activateColorArray(_colorArray.get());
arrayDispatchers.activateSecondaryColorArray(_secondaryColorArray.get()); attributeDispatchers.activateSecondaryColorArray(_secondaryColorArray.get());
arrayDispatchers.activateFogCoordArray(_fogCoordArray.get()); attributeDispatchers.activateFogCoordArray(_fogCoordArray.get());
if (state.useVertexArrayObject(_useVertexArrayObject)) if (state.useVertexArrayObject(_useVertexArrayObject))
{ {
@ -896,14 +896,14 @@ void Geometry::drawVertexArraysImplementation(RenderInfo& renderInfo) const
void Geometry::drawPrimitivesImplementation(RenderInfo& renderInfo) const void Geometry::drawPrimitivesImplementation(RenderInfo& renderInfo) const
{ {
State& state = *renderInfo.getState(); State& state = *renderInfo.getState();
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers(); AttributeDispatchers& attributeDispatchers = state.getAttributeDispatchers();
bool usingVertexBufferObjects = state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects); bool usingVertexBufferObjects = state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects);
bool bindPerPrimitiveSetActive = arrayDispatchers.active(); bool bindPerPrimitiveSetActive = attributeDispatchers.active();
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
if (bindPerPrimitiveSetActive) arrayDispatchers.dispatch(primitiveSetNum); if (bindPerPrimitiveSetActive) attributeDispatchers.dispatch(primitiveSetNum);
const PrimitiveSet* primitiveset = _primitives[primitiveSetNum].get(); const PrimitiveSet* primitiveset = _primitives[primitiveSetNum].get();

View File

@ -868,13 +868,13 @@ void SharedGeometry::drawImplementation(osg::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 SharedGeometry::drawImplementation()"); if (checkForGLErrors) state.checkGLErrors("start of SharedGeometry::drawImplementation()");
osg::ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers(); osg::AttributeDispatchers& attributeDispatchers = state.getAttributeDispatchers();
arrayDispatchers.reset(); attributeDispatchers.reset();
arrayDispatchers.setUseVertexAttribAlias(state.getUseVertexAttributeAliasing()); attributeDispatchers.setUseVertexAttribAlias(state.getUseVertexAttributeAliasing());
arrayDispatchers.activateNormalArray(_normalArray.get()); attributeDispatchers.activateNormalArray(_normalArray.get());
arrayDispatchers.activateColorArray(_colorArray.get()); attributeDispatchers.activateColorArray(_colorArray.get());
state.lazyDisablingOfVertexAttributes(); state.lazyDisablingOfVertexAttributes();