From 30f58cc3832bd1b5a5cadf4b0a4a9d47d024f9f7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 26 Jan 2024 17:48:11 +0000 Subject: Remove the static font cache Each thing can own/share a font rendering itself --- ui/text.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ui/text.h') diff --git a/ui/text.h b/ui/text.h index de2fe2e..5217050 100644 --- a/ui/text.h +++ b/ui/text.h @@ -1,5 +1,6 @@ #pragma once +#include "font.h" #include "uiComponent.h" #include #include @@ -12,7 +13,7 @@ union SDL_Event; class Text : public UIComponent { public: - Text(std::string_view s, Position, glm::vec3 colour); + Text(std::string_view s, const Font &, Position, glm::vec3 colour); void render(const UIShader &, const Position & parentPos) const override; bool handleInput(const SDL_Event &, const Position & parentPos) override; -- cgit v1.2.3 From 264640420882ceeafd9b1149eba9472cf8835e7b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 27 Jan 2024 21:47:04 +0000 Subject: Render text in N draw calls Creates a single buffer per required texture and draws the whole buffer in one go. It does introduce the use of deprecated GL_QUADS primitive, but it's the easiest way to go without needing indices, repeated vertices etc --- ui/text.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'ui/text.h') diff --git a/ui/text.h b/ui/text.h index 5217050..31ed9a5 100644 --- a/ui/text.h +++ b/ui/text.h @@ -1,12 +1,12 @@ #pragma once #include "font.h" +#include "glContainer.h" #include "uiComponent.h" #include #include #include #include -#include class UIShader; union SDL_Event; @@ -18,15 +18,12 @@ public: void render(const UIShader &, const Position & parentPos) const override; bool handleInput(const SDL_Event &, const Position & parentPos) override; -private: - struct Model { - Model(GLuint, GLsizei); - GLuint texture; - GLsizei count; - glVertexArray vao; - glBuffer vbo; - }; + Text & operator=(const std::string_view s); - std::vector models; +private: + std::vector>> models; + glContainer quads; + glVertexArray vao; glm::vec3 colour; + const Font & font; }; -- cgit v1.2.3