Commit 59b000e4 authored by Janis Born's avatar Janis Born
Browse files

VertexArrayObject: attached ArrayBuffers / ElementArrayBuffers are now const

parent 7fc547bc
......@@ -25,7 +25,7 @@ class VertexArrayObjectControl : public Resource::BasicCreateController<VertexAr
// ============================================================================================ TYPEDEFS \/
// ===================================================================================================== \/
public:
typedef std::vector<SharedArrayBuffer> ArrayBufferVec;
typedef std::vector<ConstSharedArrayBuffer> ArrayBufferVec;
// ========================================================================================================= \/
// ============================================================================================ CONSTRUCTORS \/
......@@ -46,11 +46,11 @@ public:
// ==================================================================================================== \/
public:
//! adds all attributes of an ArrayBuffer to the VAO
inline VertexArrayObjectControl& arrayBuffer(const SharedArrayBuffer& _ab)
inline VertexArrayObjectControl& arrayBuffer(const ConstSharedArrayBuffer& _ab)
{ mArrayBuffers.push_back(_ab); return *this; }
//! sets the ElementArrayBuffer for the VAO
inline VertexArrayObjectControl& elementArrayBuffer(const SharedElementArrayBuffer& _eab)
inline VertexArrayObjectControl& elementArrayBuffer(const ConstSharedElementArrayBuffer& _eab)
{ mElementArrayBuffer = _eab; return *this; }
//! links to an external LocationMappings object
......@@ -71,10 +71,10 @@ public:
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
protected:
ArrayBufferVec mArrayBuffers;
SharedElementArrayBuffer mElementArrayBuffer;
SharedLocationMappings mAttributeLocations;
GLenum mMode;
ArrayBufferVec mArrayBuffers;
ConstSharedElementArrayBuffer mElementArrayBuffer;
SharedLocationMappings mAttributeLocations;
GLenum mMode;
};
} // OpenGL
......
......@@ -101,11 +101,11 @@ public:
// ============================================================================================ GETTERS \/
// ==================================================================================================== \/
public:
inline GLuint getObjectName(void) const { return mObjectName; }
inline const AttributeVec& getAttributes(void) const { return mAttributes; }
inline GLenum getMode (void) const { return mMode; }
inline SharedElementArrayBuffer getElementArrayBuffer (void) const { return mpElementArrayBuffer; }
inline GLuint getElements (void) const { return mAttributes[0].arrayBuffer->getElements(); }
inline GLuint getObjectName() const { return mObjectName; }
inline const AttributeVec& getAttributes() const { return mAttributes; }
inline GLenum getMode() const { return mMode; }
inline ConstSharedElementArrayBuffer getElementArrayBuffer() const { return mpElementArrayBuffer; }
inline GLuint getElements() const { return mAttributes[0].arrayBuffer->getElements(); }
// ==================================================================================================== \/
// ============================================================================================ METHODS \/
......@@ -115,10 +115,10 @@ public:
* Set the given ElementArrayBuffer, if a NULL pointer is given, an existing EAB will get unset.
* Will restore the previously bound VAO (DSA style)
*/
void attachElementArrayBuffer( const SharedElementArrayBuffer& _elementArrayBuffer );
void attachElementArrayBuffer( const ConstSharedElementArrayBuffer& _elementArrayBuffer );
//! sets the EAB to NULL if there was one
inline void detachElementArrayBuffer() { attachElementArrayBuffer( SharedElementArrayBuffer() ); }
inline void detachElementArrayBuffer() { attachElementArrayBuffer( ConstSharedElementArrayBuffer() ); }
/**
* Will set the attribute _arrayBufferAttribute of ArrayBuffer _arrayBuffer to the given attribute location.
......@@ -278,11 +278,11 @@ private:
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
private:
SharedElementArrayBuffer mpElementArrayBuffer; // optional EAB
AttributeVec mAttributes; // vertex attributes
GLuint mObjectName; // OpenGL object name
GLenum mMode; // primitive type to render (e.g. GL_TRIANGLES)
GLint mPreviousVAOName; // the VAO that was bound before the last enable() call
ConstSharedElementArrayBuffer mpElementArrayBuffer; // optional EAB
AttributeVec mAttributes; // vertex attributes
GLuint mObjectName; // OpenGL object name
GLenum mMode; // primitive type to render (e.g. GL_TRIANGLES)
GLint mPreviousVAOName; // the VAO that was bound before the last enable() call
};
ACGL_SMARTPOINTER_TYPEDEFS(VertexArrayObject)
......
......@@ -27,7 +27,7 @@ VertexArrayObject::VertexArrayObject( GLenum _mode ) :
mAttributes.resize( maxAttributes ); // reserve probably 16 slots, the size() can now be used to query the MAX_VERTEX_ATTRIBS
}
void VertexArrayObject::attachElementArrayBuffer( const SharedElementArrayBuffer& _elementArrayBuffer )
void VertexArrayObject::attachElementArrayBuffer( const ConstSharedElementArrayBuffer& _elementArrayBuffer )
{
storeOldVAOandBind();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment