summaryrefslogtreecommitdiff
path: root/src/resources/openglimagehelper.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-27 22:43:59 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-27 23:15:06 +0300
commitdba24b2e59eb739e73228dbcf707e943905a9e5a (patch)
treebdbcca13bb984a47fd4f1f41d0429244777e10e9 /src/resources/openglimagehelper.cpp
parentef5ba77247a2860a201c4d9177c4f3479d53538a (diff)
downloadmanaverse-dba24b2e59eb739e73228dbcf707e943905a9e5a.tar.gz
manaverse-dba24b2e59eb739e73228dbcf707e943905a9e5a.tar.bz2
manaverse-dba24b2e59eb739e73228dbcf707e943905a9e5a.tar.xz
manaverse-dba24b2e59eb739e73228dbcf707e943905a9e5a.zip
Fix text size if it was not power of two.
Diffstat (limited to 'src/resources/openglimagehelper.cpp')
-rw-r--r--src/resources/openglimagehelper.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index badaf0223..5eae5c667 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -132,12 +132,13 @@ Image *OpenGLImageHelper::load(SDL_Surface *const tmpImage)
}
Image *OpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
+ int width, int height,
const float alpha)
{
if (!tmpImage)
return nullptr;
- Image *const img = glLoad(tmpImage);
+ Image *const img = glLoad(tmpImage, width, height);
if (img)
img->setAlpha(alpha);
return img;
@@ -159,7 +160,7 @@ int OpenGLImageHelper::powerOfTwo(int input) const
return value >= mTextureSize ? mTextureSize : value;
}
-Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage)
+Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, int width, int height)
{
if (!tmpImage)
return nullptr;
@@ -167,8 +168,10 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage)
// Flush current error flag.
glGetError();
- int width = tmpImage->w;
- int height = tmpImage->h;
+ if (!width)
+ width = tmpImage->w;
+ if (!height)
+ height = tmpImage->h;
int realWidth = powerOfTwo(width);
int realHeight = powerOfTwo(height);