MCPcopy Create free account
hub / github.com/comaps/comaps / Build

Method Build

libs/drape/mesh_object.cpp:36–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34 explicit GLMeshObjectImpl(ref_ptr<dp::MeshObject> mesh) : m_mesh(mesh) {}
35
36 void Build(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program) override
37 {
38 UNUSED_VALUE(context);
39
40 m_VAO = GLFunctions::glGenVertexArray();
41 GLFunctions::glBindVertexArray(m_VAO);
42
43 for (auto & buffer : m_mesh->m_buffers)
44 {
45 buffer->m_bufferId = GLFunctions::glGenBuffer();
46 GLFunctions::glBindBuffer(buffer->m_bufferId, gl_const::GLArrayBuffer);
47
48 if (buffer->GetSizeInBytes() != 0)
49 {
50 GLFunctions::glBufferData(gl_const::GLArrayBuffer, buffer->GetSizeInBytes(), buffer->GetData(),
51 gl_const::GLStaticDraw);
52 }
53
54 if (!m_mesh->m_indices.empty())
55 {
56 m_indexBuffer = GLFunctions::glGenBuffer();
57 GLFunctions::glBindBuffer(m_indexBuffer, gl_const::GLElementArrayBuffer);
58 GLFunctions::glBufferData(gl_const::GLElementArrayBuffer,
59 static_cast<uint32_t>(m_mesh->m_indices.size() * sizeof(uint16_t)),
60 m_mesh->m_indices.data(), gl_const::GLStaticDraw);
61 }
62
63 ref_ptr<dp::GLGpuProgram> p = program;
64 for (auto const & attribute : buffer->m_attributes)
65 {
66 int8_t const attributePosition = p->GetAttributeLocation(attribute.m_attributeName);
67 ASSERT_NOT_EQUAL(attributePosition, -1, ());
68 GLFunctions::glEnableVertexAttribute(attributePosition);
69 GLFunctions::glVertexAttributePointer(attributePosition, attribute.m_componentsCount, attribute.m_type, false,
70 buffer->GetStrideInBytes(), attribute.m_offset);
71 }
72 }
73
74 GLFunctions::glBindVertexArray(0);
75 GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
76 if (!m_mesh->m_indices.empty())
77 GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer);
78 }
79
80 void Reset() override
81 {

Callers

nothing calls this directly

Calls 7

GetSizeInBytesMethod · 0.80
GetAttributeLocationMethod · 0.80
GetStrideInBytesMethod · 0.80
GetDataMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected