Quellcode durchsuchen

Destructor and comments for Font::Text
Fixed leak of RenderTarget in Form

Adam Blake vor 13 Jahren
Ursprung
Commit
45b90b8731
3 geänderte Dateien mit 23 neuen und 0 gelöschten Zeilen
  1. 6 0
      gameplay/src/Font.cpp
  2. 16 0
      gameplay/src/Font.h
  3. 1 0
      gameplay/src/Form.cpp

+ 6 - 0
gameplay/src/Font.cpp

@@ -1722,6 +1722,12 @@ Font::Text::Text(const char* text) : _vertexCount(0), _indexCount(0)
     _indices = new unsigned short[((length - 1) * 6) + 4];
 }
 
+Font::Text::~Text()
+{
+    SAFE_DELETE_ARRAY(_vertices);
+    SAFE_DELETE_ARRAY(_indices);
+}
+
 const char* Font::Text::getText()
 {
     return _text.c_str();

+ 16 - 0
gameplay/src/Font.h

@@ -76,13 +76,29 @@ public:
         float uvs[4];
     };
 
+    /**
+     * Vertex coordinates, UVs and indices can be computed and stored in a Text object.
+     * For static text labels that do not change frequently, this means these computations
+     * need not be performed every frame.
+     */
     class Text
     {
         friend class Font;
 
     public:
+        /**
+         * Constructor.
+         */
         Text(const char* text);
 
+        /**
+         * Destructor.
+         */
+        ~Text();
+
+        /**
+         * Get the string that will be drawn from this Text object.
+         */
         const char* getText();
 
     private:

+ 1 - 0
gameplay/src/Form.cpp

@@ -164,6 +164,7 @@ void Form::setSize(float width, float height)
         RenderTarget* rt = RenderTarget::create(_id.c_str(), w, h);
         GP_ASSERT(rt);
         _frameBuffer->setRenderTarget(rt);
+        SAFE_RELEASE(rt);
 
         // Re-create projection matrix.
         Matrix::createOrthographicOffCenter(0, width, height, 0, 0, 1, &_projectionMatrix);