diff options
Diffstat (limited to 'src/mbgl/geometry')
21 files changed, 0 insertions, 732 deletions
diff --git a/src/mbgl/geometry/buffer.hpp b/src/mbgl/geometry/buffer.hpp deleted file mode 100644 index 2d010e39ac..0000000000 --- a/src/mbgl/geometry/buffer.hpp +++ /dev/null @@ -1,115 +0,0 @@ -#pragma once - -#include <mbgl/gl/context.hpp> -#include <mbgl/platform/log.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/optional.hpp> - -#include <memory> -#include <cstdlib> -#include <cassert> -#include <stdexcept> - -namespace mbgl { - -template <uint32_t item_size, - gl::BufferType target = gl::BufferType::Vertex, - uint32_t defaultLength = 8192, - bool retainAfterUpload = false> -class Buffer : private util::noncopyable { - static_assert(target == gl::BufferType::Vertex || target == gl::BufferType::Element, - "target must be one of gl::BufferType::Vertex or gl::BufferType::Element"); - -public: - ~Buffer() { - cleanup(); - } - - // Returns the number of elements in this buffer. This is not the number of - // bytes, but rather the number of coordinates with associated information. - uint32_t index() const { - return pos / itemSize; - } - - bool empty() const { - return pos == 0; - } - - // Transfers this buffer to the GPU and binds the buffer to the GL context. - void bind(gl::Context& context) { - const bool initialized { buffer }; - if (!initialized) { - buffer = context.createBuffer(); - } - - if (target == gl::BufferType::Vertex) { - context.vertexBuffer = *buffer; - } else { - context.elementBuffer = *buffer; - } - - if (!initialized) { - if (array == nullptr) { - Log::Debug(Event::OpenGL, "Buffer doesn't contain elements"); - pos = 0; - } - context.uploadBuffer(target, pos, array); - if (!retainAfterUpload) { - cleanup(); - } - } - } - - void cleanup() { - if (array) { - free(array); - array = nullptr; - } - } - - gl::BufferID getID() const { - return buffer ? *buffer : 0; - } - - // Uploads the buffer to the GPU to be available when we need it. - void upload(gl::Context& context) { - if (!buffer) { - bind(context); - } - } - -protected: - // increase the buffer size by at least /required/ bytes. - void *addElement() { - if (buffer) { - throw std::runtime_error("Can't add elements after buffer was bound to GPU"); - } - if (length < pos + itemSize) { - while (length < pos + itemSize) length += defaultLength; - array = realloc(array, length); - if (array == nullptr) { - throw std::runtime_error("Buffer reallocation failed"); - } - } - pos += itemSize; - return reinterpret_cast<char *>(array) + (pos - itemSize); - } - -public: - static constexpr const uint32_t itemSize = item_size; - -private: - // CPU buffer - void* array = nullptr; - - // Byte position where we are writing. - uint32_t pos = 0; - - // Number of bytes that are valid in this buffer. - uint32_t length = 0; - - // GL buffer object handle. - mbgl::optional<gl::UniqueBuffer> buffer; -}; - -} // namespace mbgl diff --git a/src/mbgl/geometry/circle_buffer.cpp b/src/mbgl/geometry/circle_buffer.cpp deleted file mode 100644 index cc31fb83bf..0000000000 --- a/src/mbgl/geometry/circle_buffer.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <mbgl/geometry/circle_buffer.hpp> - -#include <mbgl/gl/gl.hpp> - -#include <climits> - -namespace mbgl { - -void CircleVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey) { - vertex_type *vertices = static_cast<vertex_type *>(addElement()); - vertices[0] = (x * 2) + ((ex + 1) / 2); - vertices[1] = (y * 2) + ((ey + 1) / 2); -} - -} // namespace mbgl diff --git a/src/mbgl/geometry/circle_buffer.hpp b/src/mbgl/geometry/circle_buffer.hpp deleted file mode 100644 index 2b188c4003..0000000000 --- a/src/mbgl/geometry/circle_buffer.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include <mbgl/geometry/buffer.hpp> - -namespace mbgl { - -class CircleVertexBuffer : public Buffer< - 4 // 2 bytes per short * 4 of them. -> { -public: - typedef int16_t vertex_type; - - /* - * Add a vertex to this buffer - * - * @param {number} x vertex position - * @param {number} y vertex position - * @param {number} ex extrude normal - * @param {number} ey extrude normal - */ - void add(vertex_type x, vertex_type y, float ex, float ey); -}; - -} // namespace mbgl diff --git a/src/mbgl/geometry/collision_box_buffer.cpp b/src/mbgl/geometry/collision_box_buffer.cpp deleted file mode 100644 index ae58cf7bca..0000000000 --- a/src/mbgl/geometry/collision_box_buffer.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include <mbgl/geometry/collision_box_buffer.hpp> -#include <mbgl/gl/gl.hpp> -#include <mbgl/util/math.hpp> - -#include <cmath> - -namespace mbgl { - -uint32_t CollisionBoxVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, float maxzoom, float placementZoom) { - const uint32_t idx = index(); - void *data = addElement(); - - int16_t *shorts = static_cast<int16_t *>(data); - shorts[0] /* pos */ = x; - shorts[1] /* pos */ = y; - shorts[2] /* offset */ = ::round(ox); // use 1/64 pixels for placement - shorts[3] /* offset */ = ::round(oy); - - uint8_t *ubytes = static_cast<uint8_t *>(data); - // a_data - ubytes[8] = maxzoom * 10; - ubytes[9] = placementZoom * 10; - - return idx; -} - -} // namespace mbgl diff --git a/src/mbgl/geometry/collision_box_buffer.hpp b/src/mbgl/geometry/collision_box_buffer.hpp deleted file mode 100644 index 5360ac3f4c..0000000000 --- a/src/mbgl/geometry/collision_box_buffer.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include <mbgl/geometry/buffer.hpp> -#include <array> - -namespace mbgl { - -class CollisionBoxVertexBuffer : public Buffer < - 12, - gl::BufferType::Vertex, - 32768 -> { -public: - typedef int16_t vertex_type; - - uint32_t add(int16_t x, int16_t y, float ex, float ey, float maxzoom, float placementZoom); -}; - - -} // namespace mbgl diff --git a/src/mbgl/geometry/debug_font_buffer.cpp b/src/mbgl/geometry/debug_font_buffer.cpp deleted file mode 100644 index f64ce8816b..0000000000 --- a/src/mbgl/geometry/debug_font_buffer.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include <mbgl/geometry/debug_font_buffer.hpp> -#include <mbgl/geometry/debug_font_data.hpp> - -#include <mbgl/gl/gl.hpp> -#include <cmath> -#include <cstring> - -namespace mbgl { - -void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) { - uint16_t *coords = nullptr; - - const size_t len = strlen(text); - for (size_t i = 0; i < len; ++i) { - if (text[i] < 32 || (unsigned char)(text[i]) >= 127) { - continue; - } - - const glyph& glyph = simplex[text[i] - 32]; - - int16_t prev_x = -1, prev_y = -1, prev = false; - for (int32_t j = 0; j < glyph.length; j += 2) { - if (glyph.data[j] == -1 && glyph.data[j + 1] == -1) { - prev = false; - } else { - int16_t x = ::round(left + glyph.data[j] * scale); - int16_t y = ::round(baseline - glyph.data[j + 1] * scale); - if (prev) { - coords = static_cast<uint16_t *>(addElement()); - coords[0] = prev_x; - coords[1] = prev_y; - - coords = static_cast<uint16_t *>(addElement()); - coords[0] = x; - coords[1] = y; - } - prev_x = x; prev_y = y; prev = true; - } - } - left += glyph.width * scale; - } -} - -} // namespace mbgl diff --git a/src/mbgl/geometry/debug_font_buffer.hpp b/src/mbgl/geometry/debug_font_buffer.hpp deleted file mode 100644 index f2debe97a4..0000000000 --- a/src/mbgl/geometry/debug_font_buffer.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include <mbgl/geometry/buffer.hpp> - -namespace mbgl { - -class DebugFontBuffer : public Buffer< - 4 // 2 bytes per coordinate, 2 coordinates -> { -public: - void addText(const char *text, double left, double baseline, double scale = 1); -}; - -} // namespace mbgl diff --git a/src/mbgl/geometry/elements_buffer.cpp b/src/mbgl/geometry/elements_buffer.cpp deleted file mode 100644 index b7d8cb2015..0000000000 --- a/src/mbgl/geometry/elements_buffer.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include <mbgl/geometry/elements_buffer.hpp> - -namespace mbgl { - -void TriangleElementsBuffer::add(element_type a, element_type b, element_type c) { - element_type *elements = static_cast<element_type *>(addElement()); - elements[0] = a; - elements[1] = b; - elements[2] = c; -} - -void LineElementsBuffer::add(element_type a, element_type b) { - element_type *elements = static_cast<element_type *>(addElement()); - elements[0] = a; - elements[1] = b; -} - -} // namespace mbgl diff --git a/src/mbgl/geometry/elements_buffer.hpp b/src/mbgl/geometry/elements_buffer.hpp deleted file mode 100644 index f995229c9d..0000000000 --- a/src/mbgl/geometry/elements_buffer.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include <mbgl/geometry/buffer.hpp> -#include <mbgl/geometry/vao.hpp> - -#include <mbgl/util/noncopyable.hpp> - -#include <array> - -namespace mbgl { - -template <uint8_t count> -struct ElementGroup : public util::noncopyable { - std::array<VertexArrayObject, count> array; - uint32_t vertex_length; - uint32_t elements_length; - - ElementGroup(uint32_t vertex_length_ = 0, uint32_t elements_length_ = 0) - : vertex_length(vertex_length_) - , elements_length(elements_length_) - { - } -}; - -class TriangleElementsBuffer : public Buffer< - 6, // bytes per triangle (3 * unsigned short == 6 bytes) - gl::BufferType::Element -> { -public: - typedef uint16_t element_type; - - void add(element_type a, element_type b, element_type c); -}; - - -class LineElementsBuffer : public Buffer< - 4, // bytes per triangle (2 * unsigned short == 6 bytes) - gl::BufferType::Element -> { -public: - typedef uint16_t element_type; - - void add(element_type a, element_type b); -}; - -} // namespace mbgl diff --git a/src/mbgl/geometry/fill_buffer.cpp b/src/mbgl/geometry/fill_buffer.cpp deleted file mode 100644 index 6cb07ea66a..0000000000 --- a/src/mbgl/geometry/fill_buffer.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <mbgl/geometry/fill_buffer.hpp> - -#include <mbgl/gl/gl.hpp> - -#include <climits> - -namespace mbgl { - -void FillVertexBuffer::add(vertex_type x, vertex_type y) { - vertex_type *vertices = static_cast<vertex_type *>(addElement()); - vertices[0] = x; - vertices[1] = y; -} - -} // namespace mbgl diff --git a/src/mbgl/geometry/fill_buffer.hpp b/src/mbgl/geometry/fill_buffer.hpp deleted file mode 100644 index a180d9c5a2..0000000000 --- a/src/mbgl/geometry/fill_buffer.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include <mbgl/geometry/buffer.hpp> -#include <vector> -#include <cstdint> - -namespace mbgl { - -class FillVertexBuffer : public Buffer< - 4 // bytes per coordinates (2 * unsigned short == 4 bytes) -> { -public: - typedef int16_t vertex_type; - - void add(vertex_type x, vertex_type y); -}; - -} // namespace mbgl diff --git a/src/mbgl/geometry/icon_buffer.cpp b/src/mbgl/geometry/icon_buffer.cpp deleted file mode 100644 index 745003a548..0000000000 --- a/src/mbgl/geometry/icon_buffer.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include <mbgl/geometry/icon_buffer.hpp> -#include <mbgl/gl/gl.hpp> -#include <mbgl/util/math.hpp> - -#include <cmath> - -namespace mbgl { - -uint32_t IconVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, int16_t tx, int16_t ty, float minzoom, float maxzoom, float labelminzoom, uint8_t labelangle) { - const uint32_t idx = index(); - void *data = addElement(); - - int16_t *shorts = static_cast<int16_t *>(data); - shorts[0] /* pos */ = x; - shorts[1] /* pos */ = y; - shorts[2] /* offset */ = ::round(ox * 64); // use 1/64 pixels for placement - shorts[3] /* offset */ = ::round(oy * 64); - - uint16_t *ushorts = static_cast<uint16_t *>(data); - // a_texture_pos - ushorts[4] /* tex */ = tx / 4; - ushorts[5] /* tex */ = ty / 4; - - uint8_t *ubytes = static_cast<uint8_t *>(data); - // a_data - ubytes[12] /* labelminzoom */ = labelminzoom * 10; - ubytes[13] /* labelangle */ = labelangle; - - ubytes[14] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160. - ubytes[15] /* maxzoom */ = ::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160. - - return idx; -} - -} // namespace mbgl diff --git a/src/mbgl/geometry/icon_buffer.hpp b/src/mbgl/geometry/icon_buffer.hpp deleted file mode 100644 index 81e17df495..0000000000 --- a/src/mbgl/geometry/icon_buffer.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include <mbgl/geometry/buffer.hpp> - -#include <array> - -namespace mbgl { - - class IconVertexBuffer : public Buffer< - 16 - > { - public: - uint32_t add(int16_t x, int16_t y, float ox, float oy, int16_t tx, int16_t ty, float minzoom, float maxzoom, float labelminzoom, uint8_t labelangle); - - }; - -} // namespace mbgl diff --git a/src/mbgl/geometry/line_buffer.cpp b/src/mbgl/geometry/line_buffer.cpp deleted file mode 100644 index 0eabf8e1e9..0000000000 --- a/src/mbgl/geometry/line_buffer.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include <mbgl/geometry/line_buffer.hpp> - -#include <cmath> - -namespace mbgl { - -uint32_t LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey, bool tx, bool ty, int8_t dir, int32_t linesofar) { - uint32_t idx = index(); - void *data = addElement(); - - int16_t *coords = static_cast<int16_t *>(data); - coords[0] = (x * 2) | tx; - coords[1] = (y * 2) | ty; - - uint8_t *ubytes = static_cast<uint8_t *>(data); - // add 128 to store an byte in an unsigned byte - ubytes[4] = ::round(extrudeScale * ex) + 128; - ubytes[5] = ::round(extrudeScale * ey) + 128; - - // Encode the -1/0/1 direction value into the first two bits of .z of a_data. - // Combine it with the lower 6 bits of `linesofar` (shifted by 2 bites to make - // room for the direction value). The upper 8 bits of `linesofar` are placed in - // the `w` component. `linesofar` is scaled down by `LINE_DISTANCE_SCALE` so that - // we can store longer distances while sacrificing precision. - - // Encode the -1/0/1 direction value into .zw coordinates of a_data, which is normally covered - // by linesofar, so we need to merge them. - // The z component's first bit, as well as the sign bit is reserved for the direction, - // so we need to shift the linesofar. - - ubytes[6] = ((dir == 0 ? 0 : (dir < 0 ? -1 : 1 )) + 1) | ((linesofar & 0x3F) << 2); - ubytes[7] = linesofar >> 6; - - return idx; -} - -} // namespace mbgl diff --git a/src/mbgl/geometry/line_buffer.hpp b/src/mbgl/geometry/line_buffer.hpp deleted file mode 100644 index bfa9a55021..0000000000 --- a/src/mbgl/geometry/line_buffer.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include <mbgl/geometry/buffer.hpp> - -namespace mbgl { - -class LineVertexBuffer : public Buffer< - 8 // 2 coordinates per vertex + 1 linesofar + 1 extrude coord pair == 4 (== 8 bytes) -> { -public: - typedef int16_t vertex_type; - - /* - * Scale the extrusion vector so that the normal length is this value. - * Contains the "texture" normals (-1..1). This is distinct from the extrude - * normals for line joins, because the x-value remains 0 for the texture - * normal array, while the extrude normal actually moves the vertex to create - * the acute/bevelled line join. - */ - static const int8_t extrudeScale = 63; - - /* - * Add a vertex to this buffer - * - * @param {number} x vertex position - * @param {number} y vertex position - * @param {number} ex extrude normal - * @param {number} ey extrude normal - * @param {number} tx texture normal - * @param {number} ty texture normal - * @param {number} dir direction of the line cap (-1/0/1) - */ - uint32_t add(vertex_type x, vertex_type y, float ex, float ey, bool tx, bool ty, int8_t dir, int32_t linesofar = 0); -}; - - -} // namespace mbgl diff --git a/src/mbgl/geometry/static_vertex_buffer.cpp b/src/mbgl/geometry/static_vertex_buffer.cpp deleted file mode 100644 index c66b194748..0000000000 --- a/src/mbgl/geometry/static_vertex_buffer.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include <mbgl/geometry/static_vertex_buffer.hpp> -#include <mbgl/gl/gl.hpp> - -namespace mbgl { - -StaticVertexBuffer::StaticVertexBuffer(std::initializer_list<std::array<VertexType, 2>> init) { - for (const auto& vertex : init) { - VertexType* vertices = static_cast<VertexType*>(addElement()); - vertices[0] = std::get<0>(vertex); - vertices[1] = std::get<1>(vertex); - } -} - -StaticRasterVertexBuffer::StaticRasterVertexBuffer(std::initializer_list<std::array<VertexType, 4>> init) { - for (const auto& vertex : init) { - VertexType* vertices = static_cast<VertexType*>(addElement()); - vertices[0] = std::get<0>(vertex); - vertices[1] = std::get<1>(vertex); - vertices[2] = std::get<2>(vertex); - vertices[3] = std::get<3>(vertex); - } -} - -} // namespace mbgl diff --git a/src/mbgl/geometry/static_vertex_buffer.hpp b/src/mbgl/geometry/static_vertex_buffer.hpp deleted file mode 100644 index edf3b966fd..0000000000 --- a/src/mbgl/geometry/static_vertex_buffer.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include <mbgl/geometry/buffer.hpp> - -#include <array> -#include <cstdint> - -namespace mbgl { - -class StaticVertexBuffer : public Buffer< - 4, // bytes per vertex (2 * signed short == 4 bytes) - gl::BufferType::Vertex, - 32 // default length -> { -public: - using VertexType = int16_t; - StaticVertexBuffer(std::initializer_list<std::array<VertexType, 2>>); -}; - -class StaticRasterVertexBuffer : public Buffer< - 8, // bytes per vertex (4 * signed short == 8 bytes) - gl::BufferType::Vertex, - 32 // default length -> { -public: - using VertexType = int16_t; - StaticRasterVertexBuffer(std::initializer_list<std::array<VertexType, 4>>); -}; - -} // namespace mbgl diff --git a/src/mbgl/geometry/text_buffer.cpp b/src/mbgl/geometry/text_buffer.cpp deleted file mode 100644 index 8fed7a71d1..0000000000 --- a/src/mbgl/geometry/text_buffer.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include <mbgl/geometry/text_buffer.hpp> -#include <mbgl/gl/gl.hpp> -#include <mbgl/util/math.hpp> - -#include <cmath> - -namespace mbgl { - -uint32_t TextVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float minzoom, float maxzoom, float labelminzoom, uint8_t labelangle) { - const uint32_t idx = index(); - void *data = addElement(); - - int16_t *shorts = static_cast<int16_t *>(data); - shorts[0] /* pos */ = x; - shorts[1] /* pos */ = y; - shorts[2] /* offset */ = ::round(ox * 64); // use 1/64 pixels for placement - shorts[3] /* offset */ = ::round(oy * 64); - - uint16_t *ushorts = static_cast<uint16_t *>(data); - // a_texture_pos - ushorts[4] /* tex */ = tx / 4; - ushorts[5] /* tex */ = ty / 4; - - uint8_t *ubytes = static_cast<uint8_t *>(data); - // a_data - ubytes[12] /* labelminzoom */ = labelminzoom * 10; - ubytes[13] /* labelangle */ = labelangle; - - ubytes[14] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160. - ubytes[15] /* maxzoom */ = ::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160. - - return idx; -} - -} // namespace mbgl - diff --git a/src/mbgl/geometry/text_buffer.hpp b/src/mbgl/geometry/text_buffer.hpp deleted file mode 100644 index 4b46a38770..0000000000 --- a/src/mbgl/geometry/text_buffer.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include <mbgl/geometry/buffer.hpp> -#include <array> - -namespace mbgl { - -class TextVertexBuffer : public Buffer < - 16, - gl::BufferType::Vertex, - 32768 -> { -public: - typedef int16_t vertex_type; - - uint32_t add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float minzoom, float maxzoom, float labelminzoom, uint8_t labelangle); -}; - - -} // namespace mbgl diff --git a/src/mbgl/geometry/vao.cpp b/src/mbgl/geometry/vao.cpp deleted file mode 100644 index 2c5e1677ff..0000000000 --- a/src/mbgl/geometry/vao.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include <mbgl/geometry/vao.hpp> -#include <mbgl/gl/vertex_array.hpp> -#include <mbgl/platform/log.hpp> -#include <mbgl/util/string.hpp> -#include <mbgl/gl/gl.hpp> - -namespace mbgl { - -VertexArrayObject::VertexArrayObject() { -} - -VertexArrayObject::~VertexArrayObject() = default; - -void VertexArrayObject::bindVertexArrayObject(gl::Context& context) { - if (!gl::GenVertexArrays || !gl::BindVertexArray) { - static bool reported = false; - if (!reported) { - Log::Warning(Event::OpenGL, "Not using Vertex Array Objects"); - reported = true; - } - return; - } - - if (!vertexArray) { - vertexArray = context.createVertexArray(); - context.vertexBuffer.setDirty(); - context.elementBuffer.setDirty(); - } - - context.vertexArrayObject = *vertexArray; -} - -void VertexArrayObject::verifyBinding(Shader& shader, - gl::BufferID vertexBuffer, - gl::BufferID elementsBuffer, - int8_t* offset) { - if (bound_shader != shader.getID()) { - throw std::runtime_error(std::string("trying to rebind VAO to another shader from " + - util::toString(bound_shader) + "(" + bound_shader_name + ") to " + - util::toString(shader.getID()) + "(" + shader.name + ")" )); - } else if (bound_offset != offset) { - throw std::runtime_error("trying to bind VAO to another offset"); - } else if (bound_vertex_buffer != vertexBuffer) { - throw std::runtime_error("trying to bind VAO to another vertex buffer"); - } else if (bound_elements_buffer != elementsBuffer) { - throw std::runtime_error("trying to bind VAO to another elements buffer"); - } -} - -void VertexArrayObject::storeBinding(Shader& shader, - gl::BufferID vertexBuffer, - gl::BufferID elementsBuffer, - int8_t* offset) { - bound_shader = shader.getID(); - bound_shader_name = shader.name; - bound_offset = offset; - bound_vertex_buffer = vertexBuffer; - bound_elements_buffer = elementsBuffer; -} - -} // namespace mbgl diff --git a/src/mbgl/geometry/vao.hpp b/src/mbgl/geometry/vao.hpp deleted file mode 100644 index 65abab1e4e..0000000000 --- a/src/mbgl/geometry/vao.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include <mbgl/shader/shader.hpp> -#include <mbgl/gl/context.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/optional.hpp> - -#include <stdexcept> - -namespace mbgl { - -class VertexArrayObject : public util::noncopyable { -public: - VertexArrayObject(); - ~VertexArrayObject(); - - template <typename VertexBuffer> - void bind(Shader& shader, - VertexBuffer& vertexBuffer, - int8_t* offset, - gl::Context& context) { - bindVertexArrayObject(context); - if (bound_shader == 0) { - vertexBuffer.bind(context); - shader.bind(offset); - if (vertexArray) { - storeBinding(shader, vertexBuffer.getID(), 0, offset); - } - } else { - verifyBinding(shader, vertexBuffer.getID(), 0, offset); - } - } - - template <typename VertexBuffer, typename ElementsBuffer> - void bind(Shader& shader, - VertexBuffer& vertexBuffer, - ElementsBuffer& elementsBuffer, - int8_t* offset, - gl::Context& context) { - bindVertexArrayObject(context); - if (bound_shader == 0) { - vertexBuffer.bind(context); - elementsBuffer.bind(context); - shader.bind(offset); - if (vertexArray) { - storeBinding(shader, vertexBuffer.getID(), elementsBuffer.getID(), offset); - } - } else { - verifyBinding(shader, vertexBuffer.getID(), elementsBuffer.getID(), offset); - } - } - - gl::VertexArrayID getID() const { - return *vertexArray; - } - -private: - void bindVertexArrayObject(gl::Context&); - void storeBinding(Shader& shader, - gl::BufferID vertexBuffer, - gl::BufferID elementsBuffer, - int8_t* offset); - void verifyBinding(Shader& shader, - gl::BufferID vertexBuffer, - gl::BufferID elementsBuffer, - int8_t* offset); - - mbgl::optional<gl::UniqueVertexArray> vertexArray; - - // For debug reasons, we're storing the bind information so that we can - // detect errors and report - gl::ProgramID bound_shader = 0; - const char* bound_shader_name = ""; - gl::BufferID bound_vertex_buffer = 0; - gl::BufferID bound_elements_buffer = 0; - int8_t *bound_offset = nullptr; -}; - -} // namespace mbgl |