diff options
Diffstat (limited to 'include/llmr/geometry')
-rw-r--r-- | include/llmr/geometry/anchor.hpp | 25 | ||||
-rw-r--r-- | include/llmr/geometry/binpack.hpp | 100 | ||||
-rw-r--r-- | include/llmr/geometry/buffer.hpp | 114 | ||||
-rw-r--r-- | include/llmr/geometry/debug_font_buffer.hpp | 17 | ||||
-rw-r--r-- | include/llmr/geometry/elements_buffer.hpp | 54 | ||||
-rw-r--r-- | include/llmr/geometry/fill_buffer.hpp | 21 | ||||
-rw-r--r-- | include/llmr/geometry/geometry.hpp | 77 | ||||
-rw-r--r-- | include/llmr/geometry/glyph_atlas.hpp | 51 | ||||
-rw-r--r-- | include/llmr/geometry/icon_buffer.hpp | 20 | ||||
-rw-r--r-- | include/llmr/geometry/interpolate.hpp | 13 | ||||
-rw-r--r-- | include/llmr/geometry/line_buffer.hpp | 39 | ||||
-rw-r--r-- | include/llmr/geometry/sprite_atlas.hpp | 74 | ||||
-rw-r--r-- | include/llmr/geometry/text_buffer.hpp | 25 | ||||
-rw-r--r-- | include/llmr/geometry/vao.hpp | 101 | ||||
-rw-r--r-- | include/llmr/geometry/vertex_buffer.hpp | 35 |
15 files changed, 0 insertions, 766 deletions
diff --git a/include/llmr/geometry/anchor.hpp b/include/llmr/geometry/anchor.hpp deleted file mode 100644 index dd97c507f2..0000000000 --- a/include/llmr/geometry/anchor.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LLMR_GEOMETRY_ANCHOR -#define LLMR_GEOMETRY_ANCHOR - -#include <vector> - -namespace llmr { - -struct Anchor { - float x = 0.0f; - float y = 0.0f; - float angle = 0.0f; - float scale = 0.0f; - int segment = -1; - - explicit Anchor(float x, float y, float angle, float scale) - : x(x), y(y), angle(angle), scale(scale) {} - explicit Anchor(float x, float y, float angle, float scale, int segment) - : x(x), y(y), angle(angle), scale(scale), segment(segment) {} -}; - -typedef std::vector<Anchor> Anchors; - -} - -#endif
\ No newline at end of file diff --git a/include/llmr/geometry/binpack.hpp b/include/llmr/geometry/binpack.hpp deleted file mode 100644 index 11536ee8b3..0000000000 --- a/include/llmr/geometry/binpack.hpp +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef LLMR_GEOMETRY_BINPACK -#define LLMR_GEOMETRY_BINPACK - -#include <llmr/util/noncopyable.hpp> -#include <llmr/util/rect.hpp> -#include <cstdint> -#include <list> - -namespace llmr { - -template <typename T> -class BinPack : private util::noncopyable { -public: - BinPack(T width, T height) - : free(1, Rect<uint16_t>{ 0, 0, width, height }) {} -public: - Rect<T> allocate(T width, T height) { - // Find the smallest free rect angle - auto smallest = free.end(); - for (auto it = free.begin(); it != free.end(); ++it) { - const Rect<T>& ref = *it; - const Rect<T>& rect = *smallest; - if (width <= ref.w && height <= ref.h) { - if (smallest == free.end() || (ref.y <= rect.y && ref.x <= rect.x)) { - smallest = it; - } - } - } - - if (smallest == free.end()) { - // There's no space left for this char. - return Rect<uint16_t>{ 0, 0, 0, 0 }; - } else { - Rect<T> rect = *smallest; - free.erase(smallest); - - // Shorter/Longer Axis Split Rule (SAS) - // http://clb.demon.fi/files/RectangleBinPack.pdf p. 15 - // Ignore the dimension of R and just split long the shorter dimension - // See Also: http://www.cs.princeton.edu/~chazelle/pubs/blbinpacking.pdf - if (rect.w < rect.h) { - // split horizontally - // +--+---+ - // |__|___| <-- b1 - // +------+ <-- b2 - if (rect.w > width) free.emplace_back(rect.x + width, rect.y, rect.w - width, height); - if (rect.h > height) free.emplace_back(rect.x, rect.y + height, rect.w, rect.h - height); - } else { - // split vertically - // +--+---+ - // |__| | <-- b1 - // +--|---+ <-- b2 - if (rect.w > width) free.emplace_back(rect.x + width, rect.y, rect.w - width, rect.h); - if (rect.h > height) free.emplace_back(rect.x, rect.y + height, width, rect.h - height); - } - - return Rect<uint16_t>{ rect.x, rect.y, width, height }; - } - } - - - void release(Rect<T> rect) { - // Simple algorithm to recursively merge the newly released cell with its - // neighbor. This doesn't merge more than two cells at a time, and fails - // for complicated merges. - for (auto it = free.begin(); it != free.end(); ++it) { - Rect<T> ref = *it; - if (ref.y == rect.y && ref.h == rect.h && ref.x + ref.w == rect.x) { - ref.w += rect.w; - } - else if (ref.x == rect.x && ref.w == rect.w && ref.y + ref.h == rect.y) { - ref.h += rect.h; - } - else if (rect.y == ref.y && rect.h == ref.h && rect.x + rect.w == ref.x) { - ref.x = rect.x; - ref.w += rect.w; - } - else if (rect.x == ref.x && rect.w == ref.w && rect.y + rect.h == ref.y) { - ref.y = rect.y; - ref.h += rect.h; - } else { - continue; - } - - free.erase(it); - release(ref); - return; - - } - - free.emplace_back(rect); - }; - -private: - std::list<Rect<T>> free; -}; - -} - -#endif diff --git a/include/llmr/geometry/buffer.hpp b/include/llmr/geometry/buffer.hpp deleted file mode 100644 index 607f902bf1..0000000000 --- a/include/llmr/geometry/buffer.hpp +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef LLMR_GEOMETRY_BUFFER -#define LLMR_GEOMETRY_BUFFER - -#include <llmr/platform/gl.hpp> -#include <llmr/util/noncopyable.hpp> - -#include <cstdlib> -#include <cassert> -#include <stdexcept> - -namespace llmr { - -template < - size_t item_size, - int bufferType = GL_ARRAY_BUFFER, - size_t defaultLength = 8192, - bool retainAfterUpload = false -> -class Buffer : private util::noncopyable { -public: - ~Buffer() { - cleanup(); - if (buffer != 0) { - glDeleteBuffers(1, &buffer); - buffer = 0; - } - } - - // Returns the number of elements in this buffer. This is not the number of - // bytes, but rather the number of coordinates with associated information. - inline size_t index() const { - return pos / itemSize; - } - - inline bool empty() const { - return pos == 0; - } - - // Transfers this buffer to the GPU and binds the buffer to the GL context. - void bind(bool force = false) { - if (buffer == 0) { - glGenBuffers(1, &buffer); - force = true; - } - glBindBuffer(bufferType, buffer); - if (force) { - if (array == nullptr) { - throw std::runtime_error("Buffer was already deleted or doesn't contain elements"); - } - - glBufferData(bufferType, pos, array, GL_STATIC_DRAW); - if (!retainAfterUpload) { - cleanup(); - } - } - } - - void cleanup() { - if (array) { - free(array); - array = nullptr; - } - } - -protected: - // increase the buffer size by at least /required/ bytes. - inline void *addElement() { - if (buffer != 0) { - 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 static_cast<char *>(array) + (pos - itemSize); - } - - // Get a pointer to the item at a given index. - inline void *getElement(size_t index) { - if (array == nullptr) { - throw std::runtime_error("Buffer was already deleted or doesn't contain elements"); - } - - if (index * itemSize >= pos) { - throw new std::runtime_error("Can't get element after array bounds"); - } else { - return static_cast<char *>(array) + (index * itemSize); - } - } - -public: - static const size_t itemSize = item_size; - -private: - // CPU buffer - void *array = nullptr; - - // Byte position where we are writing. - size_t pos = 0; - - // Number of bytes that are valid in this buffer. - size_t length = 0; - - // GL buffer ID - uint32_t buffer = 0; -}; - -} - -#endif diff --git a/include/llmr/geometry/debug_font_buffer.hpp b/include/llmr/geometry/debug_font_buffer.hpp deleted file mode 100644 index 15f6daf07f..0000000000 --- a/include/llmr/geometry/debug_font_buffer.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef LLMR_GEOMETRY_DEBUG_FONT_BUFFER -#define LLMR_GEOMETRY_DEBUG_FONT_BUFFER - -#include "buffer.hpp" - -namespace llmr { - -class DebugFontBuffer : public Buffer< - 4 // 2 bytes per coordinate, 2 coordinates -> { -public: - void addText(const char *text, double left, double baseline, double scale = 1); -}; - -} - -#endif diff --git a/include/llmr/geometry/elements_buffer.hpp b/include/llmr/geometry/elements_buffer.hpp deleted file mode 100644 index a058312bda..0000000000 --- a/include/llmr/geometry/elements_buffer.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef LLMR_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER -#define LLMR_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER - -#include <llmr/geometry/buffer.hpp> -#include <llmr/geometry/vao.hpp> - -namespace llmr { - -struct ElementGroup { - VertexArrayObject array; - uint32_t vertex_length; - uint32_t elements_length; - - ElementGroup() : vertex_length(0), elements_length(0) {} - ElementGroup(uint32_t vertex_length, uint32_t elements_length) - : vertex_length(vertex_length), - elements_length(elements_length) { - } -}; - -class TriangleElementsBuffer : public Buffer< - 6, // bytes per triangle (3 * unsigned short == 6 bytes) - GL_ELEMENT_ARRAY_BUFFER -> { -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_ELEMENT_ARRAY_BUFFER -> { -public: - typedef uint16_t element_type; - - void add(element_type a, element_type b); -}; - -class PointElementsBuffer : public Buffer< - 2, // bytes per point (1 unsigned short) - GL_ELEMENT_ARRAY_BUFFER -> { -public: - typedef uint16_t element_type; - - void add(element_type a); -}; - -} - -#endif diff --git a/include/llmr/geometry/fill_buffer.hpp b/include/llmr/geometry/fill_buffer.hpp deleted file mode 100644 index 9aebe35abf..0000000000 --- a/include/llmr/geometry/fill_buffer.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef LLMR_GEOMETRY_FILL_BUFFER -#define LLMR_GEOMETRY_FILL_BUFFER - -#include "buffer.hpp" -#include <vector> -#include <cstdint> - -namespace llmr { - -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); -}; - -} - -#endif diff --git a/include/llmr/geometry/geometry.hpp b/include/llmr/geometry/geometry.hpp deleted file mode 100644 index 2f321934a7..0000000000 --- a/include/llmr/geometry/geometry.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef LLMR_GEOMETRY_GEOMETRY -#define LLMR_GEOMETRY_GEOMETRY - -#include <llmr/util/pbf.hpp> -#include <llmr/util/noncopyable.hpp> - -#include <cstdlib> - -namespace llmr { - -class Geometry : private util::noncopyable { - -public: - inline explicit Geometry(pbf& data); - - enum command : uint8_t { - end = 0, - move_to = 1, - line_to = 2, - close = 7 - }; - - inline command next(int32_t &rx, int32_t &ry); - -private: - pbf& data; - uint8_t cmd; - uint32_t length; - int32_t x, y; - int32_t ox, oy; -}; - -Geometry::Geometry(pbf& data) - : data(data), - cmd(1), - length(0), - x(0), y(0), - ox(0), oy(0) {} - -Geometry::command Geometry::next(int32_t &rx, int32_t &ry) { - if (data.data < data.end) { - if (length == 0) { - uint32_t cmd_length = static_cast<uint32_t>(data.varint()); - cmd = cmd_length & 0x7; - length = cmd_length >> 3; - } - - --length; - - if (cmd == move_to || cmd == line_to) { - rx = (x += data.svarint()); - ry = (y += data.svarint()); - - if (cmd == move_to) { - ox = x; - oy = y; - return move_to; - } else { - return line_to; - } - } else if (cmd == close) { - rx = ox; - ry = oy; - return close; - } else { - fprintf(stderr, "unknown command: %d\n", cmd); - // TODO: gracefully handle geometry parse failures - return end; - } - } else { - return end; - } -} - -} - -#endif diff --git a/include/llmr/geometry/glyph_atlas.hpp b/include/llmr/geometry/glyph_atlas.hpp deleted file mode 100644 index 0aada6a733..0000000000 --- a/include/llmr/geometry/glyph_atlas.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef LLMR_GEOMETRY_GLYPH_ATLAS -#define LLMR_GEOMETRY_GLYPH_ATLAS - -#include <llmr/geometry/binpack.hpp> -#include <llmr/text/glyph_store.hpp> - -#include <string> -#include <set> -#include <map> -#include <mutex> -#include <atomic> - -namespace llmr { - -class GlyphAtlas { -public: - -private: - struct GlyphValue { - GlyphValue(const Rect<uint16_t>& rect, uint64_t id) - : rect(rect), ids({ id }) {} - Rect<uint16_t> rect; - std::set<uint64_t> ids; - }; - -public: - GlyphAtlas(uint16_t width, uint16_t height); - ~GlyphAtlas(); - - - Rect<uint16_t> addGlyph(uint64_t tile_id, const std::string& face_name, - const SDFGlyph& glyph); - void removeGlyphs(uint64_t tile_id); - void bind(); - -public: - const uint16_t width = 0; - const uint16_t height = 0; - -private: - std::mutex mtx; - BinPack<uint16_t> bin; - std::map<std::string, std::map<uint32_t, GlyphValue>> index; - char *const data = nullptr; - std::atomic<bool> dirty; - uint32_t texture = 0; -}; - -}; - -#endif diff --git a/include/llmr/geometry/icon_buffer.hpp b/include/llmr/geometry/icon_buffer.hpp deleted file mode 100644 index 6bb0ec30c1..0000000000 --- a/include/llmr/geometry/icon_buffer.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LLMR_GEOMETRY_ICON_BUFFER -#define LLMR_GEOMETRY_ICON_BUFFER - -#include "buffer.hpp" - -namespace llmr { - - class IconVertexBuffer : public Buffer< - 4 + // int16 x/y coordinates per vertex (== 4 bytes) - 4 // uint16 x/y coordinates of icon in sprite (== 4 bytes) - > { - public: - typedef int16_t vertex_type; - - void add(vertex_type x, vertex_type y, uint16_t tx, uint16_t ty); - }; - -} - -#endif diff --git a/include/llmr/geometry/interpolate.hpp b/include/llmr/geometry/interpolate.hpp deleted file mode 100644 index 0014d56aad..0000000000 --- a/include/llmr/geometry/interpolate.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LLMR_GEOMETRY_INTERPOLATE -#define LLMR_GEOMETRY_INTERPOLATE - -#include <llmr/geometry/anchor.hpp> -#include <llmr/util/math.hpp> - -namespace llmr { - -Anchors interpolate(const std::vector<Coordinate> &vertices, float spacing, - float minScale = 0.0f, int start = 0); -} - -#endif diff --git a/include/llmr/geometry/line_buffer.hpp b/include/llmr/geometry/line_buffer.hpp deleted file mode 100644 index 289f1bc6eb..0000000000 --- a/include/llmr/geometry/line_buffer.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef LLMR_GEOMETRY_LINE_BUFFER -#define LLMR_GEOMETRY_LINE_BUFFER - -#include "buffer.hpp" - -namespace llmr { - -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 - */ - size_t add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar = 0); -}; - - -} - -#endif diff --git a/include/llmr/geometry/sprite_atlas.hpp b/include/llmr/geometry/sprite_atlas.hpp deleted file mode 100644 index 13b85e5480..0000000000 --- a/include/llmr/geometry/sprite_atlas.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef LLMR_GEOMETRY_SPRITE_ATLAS -#define LLMR_GEOMETRY_SPRITE_ATLAS - -#include <llmr/geometry/binpack.hpp> - -#include <string> -#include <map> -#include <mutex> -#include <atomic> -#include <set> - -namespace llmr { - -class Sprite; -class SpritePosition; - -class SpriteAtlas { -public: - typedef uint16_t dimension; - -public: - // Add way to construct this from another SpriteAtlas (e.g. with another pixelRatio) - SpriteAtlas(dimension width, dimension height); - ~SpriteAtlas(); - - // Changes the pixel ratio. - bool resize(float newRatio); - - // Update uninitialized sprites in this atlas from the given sprite. - void update(const Sprite &sprite); - - // Returns the coordinates of a square icon. The getter also *creates* new square icons in the - // atlas if they don't exist, but they'll be default-initialized with a a black circle. - Rect<dimension> getIcon(int size, const std::string &name); - - // Returns the coordinates of an image that is sourced from the sprite image. - // This getter does not create images, as the dimension of the texture us unknown if the - // sprite is not yet loaded. Instead, it returns a 0/0/0/0 rect. - Rect<dimension> getImage(const std::string &name, const Sprite &sprite); - - // Binds the image buffer of this sprite atlas to the GPU, and uploads data if it is out - // of date. - void bind(bool linear = false); - - inline float getWidth() const { return width; } - inline float getHeight() const { return height; } - inline float getTextureWidth() const { return width * pixelRatio; } - inline float getTextureHeight() const { return height * pixelRatio; } - -private: - void allocate(); - Rect<SpriteAtlas::dimension> allocateImage(size_t width, size_t height); - void copy(const Rect<dimension> &dst, const SpritePosition &src, const Sprite &sprite); - -public: - const dimension width = 0; - const dimension height = 0; - -private: - std::mutex mtx; - float pixelRatio = 1.0f; - BinPack<dimension> bin; - std::map<std::string, Rect<dimension>> images; - std::set<std::string> uninitialized; - uint32_t *data = nullptr; - std::atomic<bool> dirty; - uint32_t texture = 0; - uint32_t filter = 0; - static const int buffer = 1; -}; - -}; - -#endif diff --git a/include/llmr/geometry/text_buffer.hpp b/include/llmr/geometry/text_buffer.hpp deleted file mode 100644 index 8d4cba2856..0000000000 --- a/include/llmr/geometry/text_buffer.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LLMR_GEOMETRY_TEXT_BUFFER -#define LLMR_GEOMETRY_TEXT_BUFFER - -#include "buffer.hpp" -#include <array> - -namespace llmr { - -class TextVertexBuffer : public Buffer < - 16, - GL_ARRAY_BUFFER, - 32768 -> { -public: - typedef int16_t vertex_type; - - static const double angleFactor; - - size_t add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float angle, float minzoom, std::array<float, 2> range, float maxzoom, float labelminzoom); -}; - - -} - -#endif diff --git a/include/llmr/geometry/vao.hpp b/include/llmr/geometry/vao.hpp deleted file mode 100644 index 64b324372c..0000000000 --- a/include/llmr/geometry/vao.hpp +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef LLMR_GEOMETRY_VAO -#define LLMR_GEOMETRY_VAO - -#include <llmr/platform/gl.hpp> - -#include <stdexcept> - -namespace llmr { - -class VertexArrayObject { -public: - template <typename Shader, typename VertexBuffer> - void bind(Shader& shader, VertexBuffer& vertex_buffer, char *offset) { -#ifdef GL_ARB_vertex_array_object - if (!vao) { - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - } else { - // We have been given the correct information. - glBindVertexArray(vao); - } - - if (shader_ptr != &shader) { - if (shader_ptr != nullptr) { - fprintf(stderr, "shader rebind!"); - } -#endif - vertex_buffer.bind(); - shader.bind(offset); - -#ifdef GL_ARB_vertex_array_object - shader_ptr = &shader; - vertex_buffer_ptr = &vertex_buffer; - elements_buffer_ptr = nullptr; - offset_ptr = offset; - } else if (vertex_buffer_ptr != &vertex_buffer) { - throw std::runtime_error("trying to bind VAO to another vertex buffer"); - } else if (elements_buffer_ptr != nullptr) { - throw std::runtime_error("trying to bind VAO to another elements buffer"); - } else if (offset_ptr != offset) { - throw std::runtime_error("trying to bind VAO to another offset"); - } -#endif - } - - template <typename Shader, typename VertexBuffer, typename ElementsBuffer> - void bind(Shader& shader, VertexBuffer& vertex_buffer, ElementsBuffer& elements_buffer, char *offset) { -#ifdef GL_ARB_vertex_array_object - if (!vao) { - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - } else { - // We have been given the correct information. - glBindVertexArray(vao); - } - - if (shader_ptr != &shader) { -#endif - vertex_buffer.bind(); - elements_buffer.bind(); - shader.bind(offset); - -#ifdef GL_ARB_vertex_array_object - shader_ptr = &shader; - vertex_buffer_ptr = &vertex_buffer; - elements_buffer_ptr = &elements_buffer; - offset_ptr = offset; - } else if (vertex_buffer_ptr != &vertex_buffer) { - throw std::runtime_error("trying to bind VAO to another vertex buffer"); - } else if (elements_buffer_ptr != &elements_buffer) { - throw std::runtime_error("trying to bind VAO to another elements buffer"); - } else if (offset_ptr != offset) { - throw std::runtime_error("trying to bind VAO to another offset"); - } -#endif - } - - ~VertexArrayObject() { -#ifdef GL_ARB_vertex_array_object - if (vao) { - glDeleteVertexArrays(1, &vao); - } -#endif - } - -private: -#ifdef GL_ARB_vertex_array_object - GLuint vao = 0; - - // For debug reasons, we're storing the bind information so that we can - // detect errors and report - void *shader_ptr = nullptr; - void *vertex_buffer_ptr = nullptr; - void *elements_buffer_ptr = nullptr; - char *offset_ptr = 0; -#endif -}; - -} - -#endif diff --git a/include/llmr/geometry/vertex_buffer.hpp b/include/llmr/geometry/vertex_buffer.hpp deleted file mode 100644 index 9478d7b15f..0000000000 --- a/include/llmr/geometry/vertex_buffer.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef LLMR_GEOMETRY_VERTEX_BUFFER -#define LLMR_GEOMETRY_VERTEX_BUFFER - -#include <vector> -#include <cstddef> -#include <cstdint> -#include <cmath> - -namespace llmr { - -class VertexBuffer { -public: - typedef int16_t vertex_type; - VertexBuffer(std::initializer_list<vertex_type> init); - ~VertexBuffer(); - - /* - * Returns the number of elements in this buffer. This is not the number of - * bytes, but rather the number of coordinates with associated information. - */ - size_t index() const; - - /* - * Transfers this buffer to the GPU and binds the buffer to the GL context. - */ - void bind(); - -private: - const std::vector<vertex_type> array; - uint32_t buffer = 0; -}; - -} - -#endif |