ArrayBuffer.cc 1.1 KB
Newer Older
Robert Menzel's avatar
Robert Menzel committed
1
2
3
4
5
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University         //
// All rights reserved.                                                       //
////////////////////////////////////////////////////////////////////////////////

Robert Menzel's avatar
Robert Menzel committed
6
#include <ACGL/OpenGL/Objects/ArrayBuffer.hh>
Robert Menzel's avatar
Robert Menzel committed
7
8

using namespace ACGL;
Robert Menzel's avatar
Robert Menzel committed
9
using namespace ACGL::OpenGL;
Robert Menzel's avatar
Robert Menzel committed
10
11
12
13
14
15
16
17
18
19
20

int_t ArrayBuffer::getAttributeIndexByName(const std::string& _nameInArray) const
{
    for(AttributeVec::size_type i = 0; i < mAttributes.size(); ++i)
        if(mAttributes[i].name == _nameInArray)
            return i;
    return -1;
}

void ArrayBuffer::render(void) const
{
21
    glBindBuffer(GL_ARRAY_BUFFER, mContext);
Robert Menzel's avatar
Robert Menzel committed
22
23
    for(AttributeVec::size_type i = 0; i < mAttributes.size(); ++i)
    {
24
        setAttributePointer(i, i);
Robert Menzel's avatar
Robert Menzel committed
25
        glEnableVertexAttribArray(i);
26
        openGLRareError();
Robert Menzel's avatar
Robert Menzel committed
27
28
29
    }
    draw();
    for(AttributeVec::size_type i = 0; i < mAttributes.size(); ++i)
30
    {
Robert Menzel's avatar
Robert Menzel committed
31
        glDisableVertexAttribArray(i);
32
33
        openGLRareError();
    }
34
    glBindBuffer(GL_ARRAY_BUFFER, 0);
Robert Menzel's avatar
Robert Menzel committed
35
}