Commit 70431458 authored by Janis Born's avatar Janis Born
Browse files

add some error checks to VertexArrayObject::attachAttribute

parent 2e0b0057
......@@ -144,8 +144,15 @@ public:
const std::string& _arrayBufferAttributeName,
GLint _attributeLocation = -1)
{
int32_t arrayBufferAttribute = _arrayBuffer->getAttributeIndexByName(_arrayBufferAttributeName);
if(arrayBufferAttribute == -1) {
ACGL::Utils::error() << "can't attach attribute: attribute " << _arrayBufferAttributeName << " not present in array buffer" << std::endl;
return;
}
attachAttribute(_arrayBuffer,
_arrayBuffer->getAttributeIndexByName(_arrayBufferAttributeName),
arrayBufferAttribute,
_attributeLocation);
}
......
......@@ -47,7 +47,11 @@ void VertexArrayObject::attachElementArrayBuffer( const ConstSharedElementArrayB
void VertexArrayObject::attachAttribute( const Attribute &_attribute, GLint _location )
{
if ( _location >= (GLint)mAttributes.size()) {
if(_attribute.attributeID == -1) {
ACGL::Utils::error() << "can't attach attribute: invalid attribute ID" << std::endl;
return;
}
else if ( _location >= (GLint)mAttributes.size()) {
ACGL::Utils::error() << "can't attach attribute " << _attribute.arrayBuffer->getAttributes()[_attribute.attributeID].name
<< " - maximum number of attributes: " << mAttributes.size() << std::endl;
return;
......
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