Batch Font Rendering

This commit is contained in:
TheBrokenRail 2024-12-18 03:04:36 -05:00
parent b71c089fb3
commit 3771666a14
3 changed files with 25 additions and 0 deletions

View File

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

View File

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

View File

@ -280,6 +280,22 @@ static void Minecraft_setSize_injection(Minecraft_setSize_t original, Minecraft
original(self, width, height);
}
// Batch Font Rendering
template <typename... Args>
static void Font_draw_injection(const std::function<void(Args...)> &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>(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<Font *, const char *, float, float, unsigned int, bool>);
overwrite_calls(Font_drawShadow, Font_draw_injection<Font *, const std::string &, float, float, unsigned int>);
overwrite_calls(Font_drawShadow_raw, Font_draw_injection<Font *, const char *, float, float, unsigned int>);
}
}