aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2019-10-03 14:54:55 -0400
committerClyne Sullivan <clyne@bitgloo.com>2019-10-03 14:54:55 -0400
commit5b1c22529a946a782a8376de2b34c28348d078d1 (patch)
tree43668d02d8488b0385a36f072cae454f869ba440
parentad5a63db312d0029109e6ca0051feaa516419ad2 (diff)
fixes; font mem leak fix
-rw-r--r--Scripts/world.lua2
-rw-r--r--src/render.cpp3
-rw-r--r--src/text.cpp22
-rw-r--r--src/text.hpp2
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.
*/