20 std::vector<uint8_t>& bytes,
21 float x_min,
float x_max,
float bot,
float top,
26 const glm::vec3 bl { x_min, bot, 0.F };
27 const glm::vec3 br { x_max, bot, 0.F };
28 const glm::vec3 tl { x_min, top, 0.F };
29 const glm::vec3 tr { x_max, top, 0.F };
30 constexpr glm::vec3 white { 1.F, 1.F, 1.F };
32 auto write = [&](
size_t i, glm::vec3 p, glm::vec3 c,
float w, glm::vec2 uv) {
33 auto* v = bytes.data() + i * stride;
34 std::memcpy(v, &p, 12);
35 std::memcpy(v + 12, &c, 12);
36 std::memcpy(v + 24, &w, 4);
37 std::memcpy(v + 28, &uv, 8);
40 write(0, bl, bg, 0.F, {});
41 write(1, br, bg, 0.F, {});
42 write(2, tl, bg, 0.F, {});
43 write(3, br, bg, 0.F, {});
44 write(4, tr, bg, 0.F, {});
45 write(5, tl, bg, 0.F, {});
47 write(6, bl, white, 1.F, { 0.F, 1.F });
48 write(7, br, white, 1.F, { 1.F, 1.F });
49 write(8, tl, white, 1.F, { 0.F, 0.F });
50 write(9, br, white, 1.F, { 1.F, 1.F });
51 write(10, tr, white, 1.F, { 1.F, 0.F });
52 write(11, tl, white, 1.F, { 0.F, 0.F });
58 const std::shared_ptr<Core::Window>& window,
59 float x_min,
float x_max,
float row_h)
61 const auto& ws = window->get_state();
62 const auto w =
static_cast<uint32_t
>(
63 (x_max - x_min) * 0.5F *
static_cast<float>(ws.current_width));
64 const auto h =
static_cast<uint32_t
>(
65 row_h * 0.5F *
static_cast<float>(ws.current_height));
69 std::source_location::current(),
70 "Failed to get default glyph atlas for row pixel dimension calculation");
72 const uint32_t min_h = atlas->pixel_size();
73 return { std::max(w, 1U), std::max(
h, min_h) };
81 float x_min,
float x_max,
float row_h,
84 const float top = cursor.
y();
85 const float bot = top - row_h;
89 std::vector<uint8_t> bytes(
static_cast<size_t>(12) * stride, 0);
90 write_row_quad(bytes, x_min, x_max, bot, top, bg);
91 row_buf.
buf->submit(bytes);
97 .
color = { 1.F, 1.F, 1.F, 1.F },
105 const uint32_t
id = surface.
layer().
add(el);
119 label +
": " + reader(),
121 buf->bind_texture(0, text_image);
126 .buf = std::move(row_buf.
buf),
128 .link = std::move(link),
133 std::span<const ValueSpec> values,
135 std::span<const RowBuffer> row_bufs,
138 float x_min,
float x_max,
float row_h,
146 .
place(std::move(header_buf.
buf), surface, cursor, x_min, x_max, row_h);
148 std::vector<ValueRow> rows;
149 rows.reserve(values.size());
150 for (
size_t i = 0; i < values.size(); ++i) {
151 auto row =
make_value_row(values[i], row_bufs[i], surface, cursor, x_min, x_max, row_h);
152 header.attach(surface.
layer(), row.element_id);
153 rows.push_back(std::move(row));
156 header.cursor_out = cursor;
159 .
header = std::move(header),
160 .rows = std::move(rows),
GlyphAtlas * get_default_glyph_atlas() const
Return the default GlyphAtlas, or nullptr if set_default_font() has not been called successfully.
static TypeFaceFoundry & instance()
std::shared_ptr< VKBuffer > create_image_staging_buffer(size_t size)
Allocate a persistent host-visible staging buffer sized for repeated streaming uploads to an image of...
@ Runtime
General runtime operations (default fallback)
@ Portal
High-level user-facing API layer.
bool repress(const std::shared_ptr< Buffers::TextBuffer > &target, std::string_view text, glm::vec4 color, RedrawPolicy policy)
Re-composite a UTF-8 string into an existing TextBuffer.
uint32_t stride_bytes
Total bytes per vertex (stride in Vulkan terms) e.g., 3 floats (position) + 3 floats (normal) = 24 by...
static VertexLayout for_meshes(uint32_t stride=60)
Factory: layout for MeshVertex (position, color, weight, uv, normal, tangent)
Axis-aligned bounding rectangle in a 2D coordinate space.
glm::vec4 color
RGBA color applied to all glyphs.
Construction parameters for press().