diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2019-09-17 15:36:26 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2019-09-17 15:36:26 -0400 |
commit | 145d74e433216f8c17475685c553321ca4cbedf3 (patch) | |
tree | 58a06bc92cf13ae9587015cd6b9fc6dd34f919ba /src/text.cpp | |
parent | 927348d9d8eb16b469c23ef32486bea5f94c5469 (diff) |
text rendering in-place; but something's missing
Diffstat (limited to 'src/text.cpp')
-rw-r--r-- | src/text.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/text.cpp b/src/text.cpp index 186907f..1381eb2 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -1,5 +1,7 @@ #include "text.hpp" +#include "events/render.hpp" + #include <iostream> void TextSystem::configure([[maybe_unused]] entityx::EntityManager& entities, @@ -8,16 +10,30 @@ void TextSystem::configure([[maybe_unused]] entityx::EntityManager& entities, if (FT_Init_FreeType(&freetype) != 0) { // TODO handle error } + + shouldUpdateVBOs = false; } /** * Draws the text for all entities. */ void TextSystem::update([[maybe_unused]] entityx::EntityManager& entites, - [[maybe_unused]] entityx::EventManager& events, + entityx::EventManager& events, [[maybe_unused]] entityx::TimeDelta dt) { - // TODO render each Text component's text + if (shouldUpdateVBOs) { + shouldUpdateVBOs = false; + updateVBOs(); + + for (auto& data : fontData) { + auto& d = data.second; + if (d.text.size() == 0) + continue; + + // TODO make normal + events.emit<NewRenderEvent>(d.vbo, d.tex, 0, d.buffer.size()); + } + } } void TextSystem::loadFont(const std::string& name, @@ -105,7 +121,8 @@ void TextSystem::put(const std::string& font, if (fontData.find(font) == fontData.end()) return; - fontData[font].text.emplace_back(text, x, y); + fontData[font].text.emplace_back(text, x, y, -9.0f); + shouldUpdateVBOs = true; } void TextSystem::updateVBOs(void) |