diff options
Diffstat (limited to 'src/mbgl/shader/texture_rect_vertex.hpp')
-rw-r--r-- | src/mbgl/shader/texture_rect_vertex.hpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mbgl/shader/texture_rect_vertex.hpp b/src/mbgl/shader/texture_rect_vertex.hpp new file mode 100644 index 0000000000..e2e2526f16 --- /dev/null +++ b/src/mbgl/shader/texture_rect_vertex.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include <cstdint> +#include <cmath> + +namespace mbgl { + +// A vertex that holds a position, offset and texture coordinate. Used for symbol layer icons and glyphs. +class TextureRectVertex { +public: + TextureRectVertex(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) + : a_pos { + x, + y + }, + a_offset { + static_cast<int16_t>(::round(ox * 64)), // use 1/64 pixels for placement + static_cast<int16_t>(::round(oy * 64)) + }, + a_texture_pos { + static_cast<uint16_t>(tx / 4), + static_cast<uint16_t>(ty / 4) + }, + a_data { + static_cast<uint8_t>(labelminzoom * 10), // 1/10 zoom levels: z16 == 160 + static_cast<uint8_t>(labelangle), + static_cast<uint8_t>(minzoom * 10), + static_cast<uint8_t>(::fmin(maxzoom, 25) * 10) + } {} + + const int16_t a_pos[2]; + const int16_t a_offset[2]; + const uint16_t a_texture_pos[2]; + const uint8_t a_data[4]; + + static void bind(const int8_t* offset); +}; + +} // namespace mbgl |