summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/attribute.cpp
blob: 51fdd1dd121a7a5d087168d19075e318098208af (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
27
28
#include <mbgl/gl/attribute.hpp>
#include <mbgl/gl/gl.hpp>

namespace mbgl {
namespace gl {

AttributeLocation attributeLocation(ProgramID id, const char* name) {
    return MBGL_CHECK_ERROR(glGetAttribLocation(id, name));
}

void bindAttribute(AttributeLocation location,
                   std::size_t count,
                   DataType type,
                   std::size_t vertexSize,
                   std::size_t vertexOffset,
                   std::size_t attributeOffset) {
    MBGL_CHECK_ERROR(glEnableVertexAttribArray(location));
    MBGL_CHECK_ERROR(glVertexAttribPointer(
        location,
        static_cast<GLint>(count),
        static_cast<GLenum>(type),
        GL_FALSE,
        static_cast<GLsizei>(vertexSize),
        reinterpret_cast<GLvoid*>(attributeOffset + (vertexSize * vertexOffset))));
}

} // namespace gl
} // namespace mbgl