diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2020-04-24 18:43:14 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2020-04-24 18:43:14 -0400 |
commit | 3fb5e6b1eca24e536f8ab1130a7e4bd9c418fa41 (patch) | |
tree | f996d33b2dfe958e369df3c6fff567e933e29276 | |
parent | 52cfc041425a80ffd7ec63b3aaa94289ec61a977 (diff) | |
parent | 5b1c22529a946a782a8376de2b34c28348d078d1 (diff) |
Merge branch 'master' of https://github.com/tcsullivan/gamedev2 into audio
-rw-r--r-- | Scripts/world.lua | 2 | ||||
-rw-r--r-- | src/render.cpp | 3 | ||||
-rw-r--r-- | src/text.cpp | 22 | ||||
-rw-r--r-- | src/text.hpp | 2 |
4 files changed, 18 insertions, 11 deletions
diff --git a/Scripts/world.lua b/Scripts/world.lua index 3b56d9a..bb6c61e 100644 --- a/Scripts/world.lua +++ b/Scripts/world.lua @@ -103,7 +103,7 @@ world = { end end end - self:setData(1000, 1345, 5, "grass"); -- Test error checking + --self:setData(1000, 1345, 5, "grass"); -- Test error checking print("Done with world gen"); end } diff --git a/src/render.cpp b/src/render.cpp index cc7ecb1..0f0b138 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -339,9 +339,8 @@ int RenderSystem::init(void) context = SDL_GL_CreateContext(window.get()); - GLenum err; glewExperimental = GL_TRUE; - if((err=glewInit()) != GLEW_OK){ + if (auto err = glewInit(); err != GLEW_OK){ std::cerr << "GLEW was not able to initialize! Error: " << glewGetErrorString(err) << std::endl; return -1; diff --git a/src/text.cpp b/src/text.cpp index 6917a2c..fb82875 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -4,6 +4,14 @@ #include <iostream> +TextSystem::~TextSystem(void) +{ + for (auto [name, face] : fonts) + FT_Done_Face(face); + + FT_Done_FreeType(freetype); +} + void TextSystem::configure([[maybe_unused]] entityx::EntityManager& entities, [[maybe_unused]] entityx::EventManager& events) { @@ -25,12 +33,11 @@ void TextSystem::update([[maybe_unused]] entityx::EntityManager& entites, shouldUpdateVBOs = false; updateVBOs(); - for (auto& data : fontData) { - auto& d = data.second; - if (d.text.size() == 0) - continue; - - events.emit<NewRenderEvent>(d.vbo, d.tex, 0, d.buffer.size()); + for (auto& [name, font] : fontData) { + if (font.text.size() != 0) { + events.emit<NewRenderEvent>(font.vbo, font.tex, 0, + font.buffer.size()); + } } } } @@ -145,8 +152,7 @@ void TextSystem::put(const std::string& font, void TextSystem::updateVBOs(void) { - for (auto& data : fontData) { - auto& d = data.second; + for (auto& [name, d] : fontData) { d.buffer.clear(); for (auto& text : d.text) { float tx = text.x; diff --git a/src/text.hpp b/src/text.hpp index 7cf90b2..1ef2afa 100644 --- a/src/text.hpp +++ b/src/text.hpp @@ -77,6 +77,8 @@ struct Font { class TextSystem : public entityx::System<TextSystem> { public: + ~TextSystem(void); + /** * Prepares the system for running. */ |