core: rename mbgl directories to mln (#4511)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
50
src/mln/gl/drawable_gl_builder.cpp
Normal file
50
src/mln/gl/drawable_gl_builder.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <mln/gl/drawable_gl_builder.hpp>
|
||||
|
||||
#include <mln/gfx/drawable_builder_impl.hpp>
|
||||
#include <mln/gfx/drawable_impl.hpp>
|
||||
#include <mln/gl/drawable_gl.hpp>
|
||||
#include <mln/gl/drawable_gl_impl.hpp>
|
||||
#include <mln/util/convert.hpp>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace mln {
|
||||
namespace gl {
|
||||
|
||||
gfx::UniqueDrawable DrawableGLBuilder::createDrawable() const {
|
||||
return std::make_unique<DrawableGL>(drawableName.empty() ? name : drawableName);
|
||||
};
|
||||
|
||||
std::unique_ptr<gfx::Drawable::DrawSegment> DrawableGLBuilder::createSegment(gfx::DrawMode drawMode,
|
||||
SegmentBase&& seg) {
|
||||
return std::make_unique<DrawableGL::DrawSegmentGL>(drawMode, std::move(seg), VertexArray{{nullptr, false}});
|
||||
}
|
||||
|
||||
void DrawableGLBuilder::init() {
|
||||
auto& drawableGL = static_cast<DrawableGL&>(*currentDrawable);
|
||||
|
||||
drawableGL.setVertexAttrId(vertexAttrId);
|
||||
|
||||
if (impl->rawVerticesCount) {
|
||||
auto raw = impl->rawVertices;
|
||||
drawableGL.setVertices(std::move(raw), impl->rawVerticesCount, impl->rawVerticesType);
|
||||
} else {
|
||||
const auto& verts = impl->vertices.vector();
|
||||
constexpr auto vertSize = sizeof(std::remove_reference<decltype(verts)>::type::value_type);
|
||||
std::vector<uint8_t> raw(verts.size() * vertSize);
|
||||
std::memcpy(raw.data(), verts.data(), raw.size());
|
||||
drawableGL.setVertices(std::move(raw), verts.size(), gfx::AttributeDataType::Short2);
|
||||
}
|
||||
|
||||
if (!impl->sharedIndexes && !impl->buildIndexes.empty()) {
|
||||
impl->sharedIndexes = std::make_shared<gfx::IndexVectorBase>(std::move(impl->buildIndexes));
|
||||
}
|
||||
assert(impl->sharedIndexes && impl->sharedIndexes->elements());
|
||||
drawableGL.setIndexData(std::move(impl->sharedIndexes), std::move(impl->segments));
|
||||
|
||||
impl->clear();
|
||||
textures.fill(nullptr);
|
||||
}
|
||||
|
||||
} // namespace gl
|
||||
} // namespace mln
|
||||
Reference in New Issue
Block a user