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

make some members and methods const in:

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