diff --git a/examples/PoolBox/application/src/font_writer.cpp b/examples/PoolBox/application/src/font_writer.cpp index 75c85b1b..0e0207b0 100644 --- a/examples/PoolBox/application/src/font_writer.cpp +++ b/examples/PoolBox/application/src/font_writer.cpp @@ -22,7 +22,8 @@ void font_writer_setup() { void font_writer_update() { auto state = JabyEngine::State::create(JabyEngine::Make::PositionI16(8, 8), wiggle_count); - new_font_writer.write(state, "012345 ABCDEFGHIJKL\nabcedfghijkl", JabyEngine::GPU::Color24::Blue(), &wiggle); + new_font_writer.write(state, "012345 ABCDEFGHIJKL\nabcedfghijkl\n", JabyEngine::GPU::Color24::Blue(), &wiggle); + new_font_writer.write(state, "Miau: %i", JabyEngine::GPU::Color24::Red(), &wiggle, 12345); if(timer.is_expired_for(50_ms)) { timer.reset(); diff --git a/include/stdarg.h b/include/stdarg.h new file mode 100644 index 00000000..bbe0e00e --- /dev/null +++ b/include/stdarg.h @@ -0,0 +1,8 @@ +#ifndef __STDARG__H +#define __STDARG__H + +typedef __builtin_va_list va_list; +#define va_start __builtin_va_start +#define va_end __builtin_va_end + +#endif // !__STDARG__H \ No newline at end of file diff --git a/support/include/FontWriter/font_writer.hpp b/support/include/FontWriter/font_writer.hpp index 8d472766..d0aff802 100644 --- a/support/include/FontWriter/font_writer.hpp +++ b/support/include/FontWriter/font_writer.hpp @@ -1,9 +1,16 @@ #pragma once #include "Type/types.hpp" +#include namespace JabyEngine { class FontWriter { private: + #define __write_impl(start, color, wiggle) \ + va_list list; \ + va_start(list, start); \ + FontWriter::write(state, str, color, wiggle, list); \ + va_end(list) + FontBufferInfo prim_buffer; GPU::TexPage::Linked tex_page; FontPrimitive* cur_primitive; @@ -24,7 +31,18 @@ namespace JabyEngine { FontWriter::setup(buffer_info, vram_dst, Make::SizeI16(font_info.font_size.width, font_info.font_size.height)); } - void write(State& state, const char* str, GPU::Color24 color = GPU::Color24::Grey(), Wiggle* wiggle = nullptr); + void write(State& state, const char* str, ...) { + __write_impl(str, GPU::Color24::Grey(), nullptr); + } + void write(State& state, const char* str, GPU::Color24 color, ...) { + __write_impl(color, color, nullptr); + } + void write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, ...) { + __write_impl(wiggle, color, wiggle); + } + void write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, va_list b); void render(); + + #undef __write_impl }; } \ 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 0a4eb270..5bef0f75 100644 --- a/support/src/FontWriter/src/font_writer.cpp +++ b/support/src/FontWriter/src/font_writer.cpp @@ -19,7 +19,7 @@ namespace JabyEngine { } } - void FontWriter :: write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle) { + void FontWriter :: write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, va_list b) { const auto* primitive_end = &this->prim_buffer.double_buffer[GPU::Display::current_id][this->prim_buffer.single_buffer_length]; const auto font_size = this->prim_buffer.double_buffer[0][0]->size; const auto row_count = 256/font_size.width;