Prepare C arg list

This commit is contained in:
2023-12-04 21:48:27 -05:00
parent 4f44f69b40
commit 7904da6875
4 changed files with 30 additions and 3 deletions

View File

@@ -1,9 +1,16 @@
#pragma once
#include "Type/types.hpp"
#include <stdarg.h>
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
};
}

View File

@@ -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;