Moved the Array::AttribDivisor into the Array::Binding enum to avoid conflicts in settings between Binding and AttribDivisor.

Removed the vertify bindings/shared arrays handling from GeometryNew
This commit is contained in:
Robert Osfield
2013-06-05 07:27:35 +00:00
parent eb693f6a92
commit 4f1e6b28e8
3 changed files with 15 additions and 525 deletions

View File

@@ -78,11 +78,19 @@ class OSG_EXPORT Array : public BufferData
enum Binding
{
BIND_UNDEFINED=-1,
BIND_OFF=0,
BIND_OVERALL=1,
BIND_PER_PRIMITIVE_SET=2,
BIND_PER_VERTEX=4,
BIND_AUTO=5
BIND_INSTANCE_DIVISOR_0=6,
BIND_INSTANCE_DIVISOR_1=BIND_INSTANCE_DIVISOR_0+1,
BIND_INSTANCE_DIVISOR_2=BIND_INSTANCE_DIVISOR_0+2,
BIND_INSTANCE_DIVISOR_3=BIND_INSTANCE_DIVISOR_0+3,
BIND_INSTANCE_DIVISOR_4=BIND_INSTANCE_DIVISOR_0+4,
BIND_INSTANCE_DIVISOR_5=BIND_INSTANCE_DIVISOR_0+5,
BIND_INSTANCE_DIVISOR_6=BIND_INSTANCE_DIVISOR_0+6,
BIND_INSTANCE_DIVISOR_7=BIND_INSTANCE_DIVISOR_0+7
};
Array(Type arrayType=ArrayType,GLint dataSize=0,GLenum dataType=0):
@@ -91,8 +99,7 @@ class OSG_EXPORT Array : public BufferData
_dataType(dataType),
_normalize(false),
_preserveDataType(false),
_attribDivisor(false),
_binding(BIND_AUTO) {}
_binding(BIND_UNDEFINED) {}
Array(const Array& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
BufferData(array,copyop),
@@ -101,7 +108,6 @@ class OSG_EXPORT Array : public BufferData
_dataType(array._dataType),
_normalize(array._normalize),
_preserveDataType(array._preserveDataType),
_attribDivisor(array._attribDivisor),
_binding(array._binding) {}
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Array*>(obj)!=NULL; }
@@ -140,16 +146,12 @@ class OSG_EXPORT Array : public BufferData
/** Get hint to ask that the array data is passed via integer or double, or normal setVertexAttribPointer function.*/
bool getPreserveDataType() const { return _preserveDataType; }
/** Set the rate at which generic vertex attributes advance during instanced rendering. Uses the glVertexAttribDivisor feature of OpenGL 4.0*/
void setAttribDivisor(GLuint divisor) { _attribDivisor = divisor; }
/** Get the rate at which generic vertex attributes advance during instanced rendering.*/
GLuint getAttribDivisor() const { return _attribDivisor; }
/** Specify how this array should be passed to OpenGL.*/
void setBinding(Binding binding) { _binding = binding; }
void setBinding(int binding) { _binding = binding; }
/** Get how this array should be passed to OpenGL.*/
Binding getBinding() const { return _binding; }
int getBinding() const { return _binding; }
/** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/
@@ -173,8 +175,7 @@ class OSG_EXPORT Array : public BufferData
GLenum _dataType;
bool _normalize;
bool _preserveDataType;
GLuint _attribDivisor;
Binding _binding;
int _binding;
};
template<typename T, Array::Type ARRAYTYPE, int DataSize, int DataType>

View File

@@ -83,7 +83,7 @@ class OSG_EXPORT GeometryNew : public Drawable
void setSecondaryColorArray(Array* array);
Array* getSecondaryColorArray() { return _secondaryColorArray.get(); }
const Array* getSecondaryColorArray() const;
const Array* getSecondaryColorArray() const { return _secondaryColorArray.get(); }
void setFogCoordBinding(AttributeBinding ab);
@@ -177,19 +177,6 @@ class OSG_EXPORT GeometryNew : public Drawable
osg::ElementBufferObject* getOrCreateElementBufferObject();
bool verifyBindings() const;
void computeCorrectBindingsAndArraySizes();
/** check whether the arrays, indices, bindings and primitives all match correctly, return false is .*/
bool verifyArrays(std::ostream& out) const;
bool containsSharedArrays() const;
void duplicateSharedArrays();
/** Return the estimated size of GLObjects (display lists/vertex buffer objects) that are associated with this drawable.
* This size is used a hint for reuse of deleted display lists/vertex buffer objects. */
@@ -237,9 +224,6 @@ class OSG_EXPORT GeometryNew : public Drawable
virtual ~GeometryNew();
bool verifyBindings(const osg::ref_ptr<Array>& array) const;
void computeCorrectBindingsAndArraySizes(osg::ref_ptr<Array>& ,const char* arrayName);
void addVertexBufferObjectIfRequired(osg::Array* array);
void addElementBufferObjectIfRequired(osg::PrimitiveSet* primitiveSet);