]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
fixes; font mem leak fix
authorClyne Sullivan <clyne@bitgloo.com>
Thu, 3 Oct 2019 18:54:55 +0000 (14:54 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Thu, 3 Oct 2019 18:54:55 +0000 (14:54 -0400)
Scripts/world.lua
src/render.cpp
src/text.cpp
src/text.hpp

index 3b56d9ae9ef86c1f8e1aa3c11d201188eeea8952..bb6c61ea52973b5a2d5a13997a6e54c45efbb780 100644 (file)
@@ -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
 }
index cc7ecb15958664d2dadb2e099c36569df09d42f9..0f0b138106f1216c77bb06cf7f5a7747e04e22a1 100644 (file)
@@ -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;
index 6917a2cd26ca026c4a6a4ce220e1703dfc89054f..fb828759eff71e45d0de2de0c07e6dd148465661 100644 (file)
@@ -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;
index 7cf90b2fd7dbb3c783133a1b1734667eb6adf6c0..1ef2afaac72ff3411688165b2ba0981ff17679e8 100644 (file)
@@ -77,6 +77,8 @@ struct Font {
 class TextSystem : public entityx::System<TextSystem>
 {
 public:
+    ~TextSystem(void);
+
     /**
      * Prepares the system for running.
      */