Commit 5d72815a authored by Janis Born's avatar Janis Born

make some members and methods const in:

* Buffer
* ShaderProgram
* VertexArrayObject
parent ed09d0bc
......@@ -98,7 +98,7 @@ public:
mTarget(_target)
{}
virtual ~Buffer(){}
virtual ~Buffer(){}
// ==================================================================================================== \/
// ============================================================================================ GETTERS \/
......@@ -119,7 +119,8 @@ public:
// ============================================================================================ WRAPPERS \/
// ===================================================================================================== \/
private:
inline GLint getParameter( GLenum _parameter ) {
inline GLint getParameter( GLenum _parameter ) const
{
bind( mTarget );
GLint value;
glGetBufferParameteriv( mTarget, _parameter, &value );
......@@ -127,7 +128,8 @@ private:
}
#if (ACGL_OPENGL_VERSION >= 32)
inline GLint64 getParameter64( GLenum _parameter ) {
inline GLint64 getParameter64( GLenum _parameter ) const
{
bind( mTarget );
GLint64 value;
glGetBufferParameteri64v( mTarget, _parameter, &value );
......@@ -137,32 +139,31 @@ private:
public:
//! not side effect free! will bind this buffer to it's last target!
//! caching of these values on RAM could be a good idea if needed very(!) often (as it's done with the size)!
//inline GLint64 getSize() { return getParameter64( GL_BUFFER_SIZE ); }
inline GLint64 getMapOffset() { return getParameter64( GL_BUFFER_MAP_OFFSET ); }
inline GLint64 getMapLength() { return getParameter64( GL_BUFFER_MAP_LENGTH ); }
//inline GLint64 getSize() const { return getParameter64( GL_BUFFER_SIZE ); }
inline GLint64 getMapOffset() const { return getParameter64( GL_BUFFER_MAP_OFFSET ); }
inline GLint64 getMapLength() const { return getParameter64( GL_BUFFER_MAP_LENGTH ); }
#else // OpenGL pre 3.2:
//inline GLint getSize() { return getParameter ( GL_BUFFER_SIZE ); }
inline GLint getMapOffset() { return getParameter ( GL_BUFFER_MAP_OFFSET ); }
inline GLint getMapLength() { return getParameter ( GL_BUFFER_MAP_LENGTH ); }
//inline GLint getSize() const { return getParameter ( GL_BUFFER_SIZE ); }
inline GLint getMapOffset() const { return getParameter ( GL_BUFFER_MAP_OFFSET ); }
inline GLint getMapLength() const { return getParameter ( GL_BUFFER_MAP_LENGTH ); }
#endif // OpenGL >= 3.2
inline GLenum getUsage() { return (GLenum) getParameter ( GL_BUFFER_USAGE ); }
inline GLenum getAccess() { return (GLenum) getParameter ( GL_BUFFER_ACCESS ); }
inline GLint getAccessFlags() { return (GLint) getParameter ( GL_BUFFER_ACCESS_FLAGS ); }
inline GLboolean isMapped() { return (GLboolean) getParameter ( GL_BUFFER_MAPPED ); }
inline GLenum getUsage() const { return (GLenum) getParameter ( GL_BUFFER_USAGE ); }
inline GLenum getAccess() const { return (GLenum) getParameter ( GL_BUFFER_ACCESS ); }
inline GLint getAccessFlags() const { return (GLint) getParameter ( GL_BUFFER_ACCESS_FLAGS ); }
inline GLboolean isMapped() const { return (GLboolean) getParameter ( GL_BUFFER_MAPPED ); }
//! the size is in bytes
inline GLint64 getSize() { return mSize; }
inline GLint64 getSize() const { return mSize; }
//! Bind this buffer
inline void bind( GLenum _target )
inline void bind( GLenum _target ) const
{
glBindBuffer( _target, mBuffer->mObjectName );
openGLRareError();
}
//! Bind this buffer to its target
inline void bind()
inline void bind() const
{
glBindBuffer( mTarget, mBuffer->mObjectName );
openGLRareError();
......@@ -318,8 +319,8 @@ public:
// =================================================================================================== \/
protected:
GLint64 mSize; // as this might get queried often (e.g. ArrayBuffer) we will explicitly mirror it in RAM - bytes
SharedBufferObject mBuffer;
GLenum mTarget;
SharedBufferObject mBuffer;
GLenum mTarget;
};
ACGL_SMARTPOINTER_TYPEDEFS(Buffer)
......
......@@ -156,7 +156,7 @@ public:
//! Sets the attribute locations of this ShaderProgram according to the mappings specified in _locationMappings
void setAttributeLocations( ConstSharedLocationMappings _locationMappings );
//! Get all attribute names with there locations:
SharedLocationMappings getAttributeLocations();
SharedLocationMappings getAttributeLocations() const;
//////////// fragdata locations:
#if (ACGL_OPENGL_VERSION >= 30)
......
......@@ -52,8 +52,8 @@ class VertexArrayObject
public:
struct Attribute
{
SharedArrayBuffer arrayBuffer; // the ArrayBuffer to use
int32_t attributeID; // the attribute from that ArrayBuffer
ConstSharedArrayBuffer arrayBuffer; // the ArrayBuffer to use
int32_t attributeID; // the attribute from that ArrayBuffer
// more Attribute properties can be looked up in the ArrayBuffer (like the name)
};
......@@ -126,7 +126,7 @@ public:
* The _attributeLocation has to be lower than GL_MAX_VERTEX_ATTRIBS
* An attribute location of -1 indicates that the attribute should get the next free location
*/
inline void attachAttribute( const SharedArrayBuffer& _arrayBuffer,
inline void attachAttribute( const ConstSharedArrayBuffer& _arrayBuffer,
uint32_t _arrayBufferAttribute,
GLint _attributeLocation = -1)
{
......@@ -140,7 +140,7 @@ public:
* The _attributeLocation has to be lower than GL_MAX_VERTEX_ATTRIBS
* An attribute location of -1 indicates that the attribute should should get the next free location
*/
inline void attachAttribute( const SharedArrayBuffer& _arrayBuffer,
inline void attachAttribute( const ConstSharedArrayBuffer& _arrayBuffer,
const std::string& _arrayBufferAttributeName,
GLint _attributeLocation = -1)
{
......@@ -158,7 +158,7 @@ public:
* The attributes are attached to the next free location.
* Afterwards, you might want to automatically wire up the attributes with a ShaderProgram, using setAttributeLocationsByShaderProgram
*/
void attachAllAttributes( const SharedArrayBuffer& _arrayBuffer );
void attachAllAttributes( const ConstSharedArrayBuffer& _arrayBuffer );
/**
* Will detach the Attribute with the given attribute location.
......@@ -177,7 +177,7 @@ public:
void setAttributeLocations( ConstSharedLocationMappings _locationMappings );
//! get a list of attribute locations and names that can be used to set up a ShaderProgram
SharedLocationMappings getAttributeLocations();
SharedLocationMappings getAttributeLocations() const;
private:
//! Sets the vertex attribute pointer for the current VAO according to the specified attribute (index into mAttributes)
......@@ -270,7 +270,7 @@ private:
private:
SharedElementArrayBuffer mpElementArrayBuffer; // optional EAB
AttributeVec mAttributes; // vertex attributes
GLuint mObjectName; // OpenGL object name
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
};
......
......@@ -117,7 +117,7 @@ void ShaderProgram::setFragmentDataLocations(ConstSharedLocationMappings _locati
}
}
SharedLocationMappings ShaderProgram::getAttributeLocations()
SharedLocationMappings ShaderProgram::getAttributeLocations() const
{
SharedLocationMappings locationMap = SharedLocationMappings( new LocationMappings() );
......
......@@ -84,7 +84,7 @@ GLint VertexArrayObject::getFreeAttributeLocation()
return -1;
}
void VertexArrayObject::attachAllAttributes( const SharedArrayBuffer& _arrayBuffer )
void VertexArrayObject::attachAllAttributes( const ConstSharedArrayBuffer& _arrayBuffer )
{
ArrayBuffer::AttributeVec attributes = _arrayBuffer->getAttributes();
for(ArrayBuffer::AttributeVec::size_type i = 0; i < attributes.size(); ++i)
......@@ -190,7 +190,7 @@ void VertexArrayObject::setAttributeLocations( ConstSharedLocationMappings _loca
}
SharedLocationMappings VertexArrayObject::getAttributeLocations()
SharedLocationMappings VertexArrayObject::getAttributeLocations() const
{
SharedLocationMappings locationMap = SharedLocationMappings( new LocationMappings() );
......
Markdown is supported
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