Browse Source

Fixed issue with font stretching when drawing onto a frame buffer that is a different size than the original window size.

Steve Grenier 12 years ago
parent
commit
a61f2701de
2 changed files with 8 additions and 10 deletions
  1. 8 0
      gameplay/src/Font.cpp
  2. 0 10
      gameplay/src/Theme.cpp

+ 8 - 0
gameplay/src/Font.cpp

@@ -154,6 +154,14 @@ unsigned int Font::getSize()
 void Font::start()
 {
     GP_ASSERT(_batch);
+
+    // Update the projection matrix for our batch to match the current viewport
+    const Rectangle& vp = Game::getInstance()->getViewport();
+    Game* game = Game::getInstance();
+    Matrix projectionMatrix;
+    Matrix::createOrthographicOffCenter(vp.x, vp.width, vp.height, vp.y, 0, 1, &projectionMatrix);
+    _batch->setProjectionMatrix(projectionMatrix);
+
     _batch->start();
 }
 

+ 0 - 10
gameplay/src/Theme.cpp

@@ -488,16 +488,6 @@ void Theme::setProjectionMatrix(const Matrix& matrix)
 {
     GP_ASSERT(_spriteBatch);
     _spriteBatch->setProjectionMatrix(matrix);
-
-    // Set the matrix on each Font used by the style.
-    std::set<Font*>::const_iterator it;
-    for (it = _fonts.begin(); it != _fonts.end(); ++it)
-    {
-        Font* font = *it;
-        GP_ASSERT(font);
-        GP_ASSERT(font->getSpriteBatch());
-        font->getSpriteBatch()->setProjectionMatrix(matrix);
-    }
 }
 
 SpriteBatch* Theme::getSpriteBatch() const