From 57798eec9f9a7017dd7add477232d6352e3d11f8 Mon Sep 17 00:00:00 2001 From: Jaby Blubb Date: Sat, 25 Nov 2023 17:23:49 +0100 Subject: [PATCH] Prepare Font double buffer --- Support/include/FontWriter/Type/types.hpp | 17 +++++++++++++++++ Support/include/FontWriter/font_writer.hpp | 2 +- Support/src/FontWriter/src/font_writer.cpp | 19 ++++++++++++++++++- examples/PoolBox/application/src/main.cpp | 5 +++-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Support/include/FontWriter/Type/types.hpp b/Support/include/FontWriter/Type/types.hpp index 90e7b1fb..1b063294 100644 --- a/Support/include/FontWriter/Type/types.hpp +++ b/Support/include/FontWriter/Type/types.hpp @@ -1,10 +1,27 @@ #pragma once #include +#include #include namespace JabyEngine { + using FontPrimitive = GPU::SPRT::Linked; + struct FontInfo { GPU::SizeU16 VRAMSize; GPU::SizeU16 FontSize; }; + + struct FontBufferInfo { + FontPrimitive* double_buffer[2]; + size_t single_buffer_length; + + static constexpr FontBufferInfo empty() { + return FontBufferInfo{.double_buffer = {nullptr, nullptr}, .single_buffer_length = 0}; + } + + template + static constexpr FontBufferInfo from(FontPrimitive (&buffer)[2][N]) { + return FontBufferInfo{.double_buffer = {buffer[0], buffer[1]}, .single_buffer_length = N}; + } + }; } diff --git a/Support/include/FontWriter/font_writer.hpp b/Support/include/FontWriter/font_writer.hpp index 352cee29..d2badc56 100644 --- a/Support/include/FontWriter/font_writer.hpp +++ b/Support/include/FontWriter/font_writer.hpp @@ -3,6 +3,6 @@ namespace JabyEngine { struct FontWriter { - static void setup(SimpleTIM vram_dst, const FontInfo& font_info); + static void setup(const FontBufferInfo& buffer_info, SimpleTIM vram_dst, const FontInfo& font_info); }; } \ No newline at end of file diff --git a/Support/src/FontWriter/src/font_writer.cpp b/Support/src/FontWriter/src/font_writer.cpp index 10e583bc..992b30ec 100644 --- a/Support/src/FontWriter/src/font_writer.cpp +++ b/Support/src/FontWriter/src/font_writer.cpp @@ -2,7 +2,24 @@ #include namespace JabyEngine { - void FontWriter :: setup(SimpleTIM vram_dst, const FontInfo& font_info) { + struct DoubleBuffer { + // Hooks? + FontBufferInfo prim_buffer; + + static constexpr DoubleBuffer empty() { + return DoubleBuffer{.prim_buffer = FontBufferInfo::empty()}; + } + + void setup(const FontBufferInfo& buffer_info) { + this->prim_buffer = buffer_info; + } + }; + + static auto double_buffer = DoubleBuffer::empty(); + + void FontWriter :: setup(const FontBufferInfo& buffer_info, SimpleTIM vram_dst, const FontInfo& font_info) { + double_buffer.setup(buffer_info); + printf("Hello Planschi c:\n"); } } \ No newline at end of file diff --git a/examples/PoolBox/application/src/main.cpp b/examples/PoolBox/application/src/main.cpp index 1aee0ce0..24c249a1 100644 --- a/examples/PoolBox/application/src/main.cpp +++ b/examples/PoolBox/application/src/main.cpp @@ -12,13 +12,14 @@ using namespace JabyEngine; using NewFontWriter = ::JabyEngine::FontWriter; -static object::Paco paco; +static object::Paco paco; +static FontPrimitive font_buffer[2][256]; static void setup() { static constexpr auto FontTIM = SimpleTIM(320, 0, 320, DefaultFont::Info.VRAMSize.height); DefaultFont::load(&__heap_start, FontTIM); - NewFontWriter::setup(FontTIM, DefaultFont::Info); + NewFontWriter::setup(FontBufferInfo::from(font_buffer), FontTIM, DefaultFont::Info); Assets::load_for_main(); FontWriter::FontWriter::setup();