summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/vertex_array.cpp
blob: e82e6e9765c3a9532d93617ed3cbd35f2560446a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <mbgl/gl/vertex_array.hpp>
#include <mbgl/gl/index_buffer_resource.hpp>
#include <mbgl/gl/context.hpp>

namespace mbgl {
namespace gl {

void VertexArray::bind(Context& context,
                       const gfx::IndexBuffer& indexBuffer,
                       const AttributeBindingArray& bindings) {
    context.bindVertexArray = state->vertexArray;
    state->indexBuffer = indexBuffer.getResource<gl::IndexBufferResource>().buffer;

    state->bindings.reserve(bindings.size());

    // NOLINTNEXTLINE(bugprone-too-small-loop-variable)
    for (AttributeLocation location = 0; location < bindings.size(); ++location) {
        if (state->bindings.size() <= location) {
            state->bindings.emplace_back(context, AttributeLocation(location));
        }
        state->bindings[location] = bindings[location];
    }
}

} // namespace gl
} // namespace mbgl