Support clearing existing text

This commit is contained in:
Jaby 2024-01-03 22:44:33 -06:00
parent 839b9a45c3
commit 33755cc2e9
2 changed files with 7 additions and 1 deletions

View File

@ -34,6 +34,8 @@ namespace JabyEngine {
FontWriter::setup(vram_dst, Make::SizeI16(font_info.font_size.width, font_info.font_size.height));
}
void clear();
void write(State& state, const char* str, ...) {
__write_impl(str, GPU::Color24::Grey(), nullptr);
}

View File

@ -63,13 +63,17 @@ namespace JabyEngine {
this->last_primitive = nullptr;
}
void FontWriter :: clear() {
this->last_primitive = &this->tex_page[GPU::update_id()];
}
void FontWriter :: write(State& state, const char* str, GPU::Color24 color, const Wiggle* wiggle, va_list list) {
static const auto exchang_str = [](const char* str, const char* new_str) -> pair<const char*, const char*> {
return {str + 1, new_str};
};
if(!this->last_primitive) {
this->last_primitive = &this->tex_page[GPU::update_id()];
FontWriter::clear();
}
const auto row_count = 256/font_size.width;