silly
parent
04cf8158c4
commit
ed6f36020e
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
include(FetchContent)
|
||||
|
||||
set(BLT_GRAPHICS_VERSION 1.0.9)
|
||||
set(BLT_GRAPHICS_VERSION 1.0.10)
|
||||
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
|
||||
|
||||
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
||||
|
|
|
@ -69,15 +69,25 @@ namespace blt::gfx
|
|||
class font_generator_t
|
||||
{
|
||||
public:
|
||||
|
||||
struct size_bounds_t
|
||||
{
|
||||
float min_size, max_size;
|
||||
blt::u64 min_char, max_char;
|
||||
};
|
||||
|
||||
struct bounded_font_t
|
||||
{
|
||||
std::unique_ptr<font_texture_atlas> atlas;
|
||||
float min_size, max_size;
|
||||
blt::u64 min_char, max_char;
|
||||
// float min_size, max_size;
|
||||
// blt::u64 min_char, max_char;
|
||||
std::vector<size_bounds_t> size_limits;
|
||||
|
||||
bounded_font_t(std::unique_ptr<font_texture_atlas> atlas, float minSize, float maxSize, u64 minChar, u64 maxChar):
|
||||
atlas(std::move(atlas)), min_size(minSize), max_size(maxSize), min_char(minChar), max_char(maxChar)
|
||||
explicit bounded_font_t(std::unique_ptr<font_texture_atlas> atlas): atlas(std::move(atlas))
|
||||
{}
|
||||
// bounded_font_t(std::unique_ptr<font_texture_atlas> atlas, float minSize, float maxSize, u64 minChar, u64 maxChar):
|
||||
// atlas(std::move(atlas)), min_size(minSize), max_size(maxSize), min_char(minChar), max_char(maxChar)
|
||||
// {}
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -89,6 +99,7 @@ namespace blt::gfx
|
|||
{
|
||||
for (auto& atlas : atlases)
|
||||
{
|
||||
BLT_TRACE("(%f %ld), %f %f, %ld %ld", size, c, atlas.min_size, atlas.max_size, atlas.min_char, atlas.max_char);
|
||||
if (!(size >= atlas.min_size && size <= atlas.max_size))
|
||||
continue;
|
||||
if (c >= atlas.min_char && c <= atlas.max_char)
|
||||
|
@ -188,18 +199,21 @@ namespace blt::gfx
|
|||
};
|
||||
|
||||
font_generator_t& generator;
|
||||
std::string contents;
|
||||
vertex_array_t vao{};
|
||||
std::vector<text_render_info_t> renders;
|
||||
blt::vec2f position;
|
||||
blt::vec2f scale = {1, 1};
|
||||
blt::vec4 color = blt::make_color(1, 1, 1);
|
||||
float z_index = 0;
|
||||
float current_size = 0;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit font_renderer_t();
|
||||
|
||||
void create_default(blt::i32 dimensions = 0);
|
||||
|
||||
void create(const std::vector<float>& generated_font_sizes, blt::i32 dimensions = 0);
|
||||
|
||||
void cleanup();
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace blt::gfx
|
|||
|
||||
void font_renderer_t::create_default(blt::i32 dimensions)
|
||||
{
|
||||
create({9, 11, 12, 13, 14, 16, 18, 24, 32, 36, 40, 48, 52, 64, 72, 96, 106}, dimensions);
|
||||
create({9, 11, 12, 13, 14, 16, 18, 24, 32, 36, 40, 48, 52, 64, 72, 96, 106, 250}, dimensions);
|
||||
|
||||
add_default_font(reinterpret_cast<const blt::u8*>(font::default_font_compressed_data), font::default_font_compressed_size, true);
|
||||
}
|
||||
|
@ -241,6 +241,10 @@ namespace blt::gfx
|
|||
|
||||
void font_renderer_t::compiled_text_t::change_text(std::string_view str, float size)
|
||||
{
|
||||
if (str == contents)
|
||||
return;
|
||||
contents = str;
|
||||
current_size = size;
|
||||
static std::vector<float> vertices;
|
||||
vertices.clear();
|
||||
renders.clear();
|
||||
|
@ -325,4 +329,6 @@ namespace blt::gfx
|
|||
glDrawArrays(GL_TRIANGLES, static_cast<int>(render.render_start), static_cast<int>(render.render_count));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue