diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 22f0a5afb0..df09f2c937 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -58,6 +58,7 @@ * `Close Editor When Sign Is Destroyed` (Enabled By Default) * `Remove Chest Placement Restrictions` (Enabled By Default) * `Fix Hanging When No Valid Spawn Point Exists` (Enabled By Default) + * `Batch Font Rendering` (Enabled By Default) * Existing Functionality (All Enabled By Default) * `Fix Screen Rendering When Hiding HUD` * `Sanitize Usernames` diff --git a/libreborn/src/util/env/flags/available-feature-flags b/libreborn/src/util/env/flags/available-feature-flags index 66e3a778c6..1661516244 100644 --- a/libreborn/src/util/env/flags/available-feature-flags +++ b/libreborn/src/util/env/flags/available-feature-flags @@ -49,6 +49,7 @@ CATEGORY Rendering TRUE Optimized Chunk Sorting TRUE Multidraw Rendering TRUE Increase Render Chunk Size + TRUE Batch Font Rendering CATEGORY Camera TRUE Enable Camera Rendering TRUE Render Camera Legs diff --git a/mods/src/misc/ui.cpp b/mods/src/misc/ui.cpp index b859f82ac3..316fe0826c 100644 --- a/mods/src/misc/ui.cpp +++ b/mods/src/misc/ui.cpp @@ -280,6 +280,22 @@ static void Minecraft_setSize_injection(Minecraft_setSize_t original, Minecraft original(self, width, height); } +// Batch Font Rendering +template +static void Font_draw_injection(const std::function &original, Args... args) { + Tesselator &t = Tesselator::instance; + const bool was_already_overridden = t.void_begin_end; + if (!was_already_overridden) { + t.begin(GL_QUADS); + t.voidBeginAndEndCalls(true); + } + original(std::forward(args)...); + if (!was_already_overridden) { + t.voidBeginAndEndCalls(false); + t.draw(); + } +} + // Init void _init_misc_ui() { // Food Overlay @@ -392,4 +408,11 @@ void _init_misc_ui() { // Fix Signs overwrite_calls(LocalPlayer_openTextEdit, LocalPlayer_openTextEdit_injection); } + + // Batch Font Rendering + if (feature_has("Batch Font Rendering", server_disabled)) { + overwrite_calls(Font_drawSlow, Font_draw_injection); + overwrite_calls(Font_drawShadow, Font_draw_injection); + overwrite_calls(Font_drawShadow_raw, Font_draw_injection); + } }