diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-27 21:47:04 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-27 21:47:04 +0000 |
commit | 264640420882ceeafd9b1149eba9472cf8835e7b (patch) | |
tree | dad2b2cbe2bc8bf5560f4859880549472f808671 /ui/text.h | |
parent | Add traits vertex attrib func override for arrays (diff) | |
download | ilt-264640420882ceeafd9b1149eba9472cf8835e7b.tar.bz2 ilt-264640420882ceeafd9b1149eba9472cf8835e7b.tar.xz ilt-264640420882ceeafd9b1149eba9472cf8835e7b.zip |
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
Diffstat (limited to 'ui/text.h')
-rw-r--r-- | ui/text.h | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -1,12 +1,12 @@ #pragma once #include "font.h" +#include "glContainer.h" #include "uiComponent.h" #include <glArrays.h> #include <glad/gl.h> #include <glm/glm.hpp> #include <string_view> -#include <vector> 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<Model> models; +private: + std::vector<std::pair<GLuint, std::pair<GLsizei, GLint>>> models; + glContainer<Font::Quad> quads; + glVertexArray vao; glm::vec3 colour; + const Font & font; }; |