Change to double buffering and SPRT_16

This commit is contained in:
2023-12-20 15:12:21 -05:00
parent d7fce900f9
commit 4bf87bc85f
5 changed files with 23 additions and 13 deletions

View File

@@ -48,10 +48,12 @@ namespace JabyEngine {
}
void FontWriter :: setup(const SimpleTIM& vram_dst, const GPU::SizeI16& font_size) {
this->tex_page = Make::TexPage(vram_dst.get_texture_position(), GPU::TexturePageColor::$4bit).linked();
for(auto& tex_page : this->tex_page) {
tex_page = Make::TexPage(vram_dst.get_texture_position(), GPU::TexturePageColor::$4bit).linked();
}
this->font_size = font_size;
this->clut = Make::PageClut(vram_dst.get_clut_position());
this->last_primitive = &this->tex_page;
this->last_primitive = nullptr;
}
void FontWriter :: write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, va_list list) {
@@ -59,13 +61,15 @@ namespace JabyEngine {
return {str + 1, new_str};
};
if(!this->last_primitive) {
this->last_primitive = &this->tex_page[GPU::update_id()];
}
const auto row_count = 256/font_size.width;
const auto push_char = [&](State& state, char cur_char) -> bool {
auto& primitive = GlobalPrimitiveFactory.new_primitive();
primitive->position = state.pos;
primitive->size = this->font_size;
if(wiggle) {
const auto [off_x, off_y] = (*wiggle)[(state.wiggle_count++)&0x7];
primitive->position.move(off_x, off_y);
@@ -131,12 +135,9 @@ namespace JabyEngine {
}
void FontWriter :: render() {
const auto update_id = GPU::Display::current_id;
const auto render_id = update_id ^ 1;
this->last_primitive->terminate();
this->last_primitive = &this->tex_page;
this->last_primitive = nullptr;
GPU::render(this->tex_page);
GPU::render(this->tex_page[GPU::render_id()]);
}
}

View File

@@ -8,7 +8,7 @@ namespace JabyEngine {
const auto*const buffer_end = start + length;
for(auto* cur_prim = start; cur_prim < buffer_end; cur_prim++) {
*cur_prim = FontPrimitive::create(GPU::SPRT::create(Make::AreaI16(), Make::OffsetPageWithClut()));
*cur_prim = FontPrimitive::create(Make::SPRT_16(Make::Vertex(), Make::OffsetPageWithClut()));
}
GlobalPrimitiveFactory = PrimitiveFactory::create(start, length);