summaryrefslogtreecommitdiff
path: root/src/mobileopenglgraphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-26 19:27:35 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-26 19:27:35 +0300
commita1a00f0ed5366cfb8dbe448078ccc60331a0cdaa (patch)
tree53118e9c8513217746f16e2cca7ed894b2c4e39f /src/mobileopenglgraphics.cpp
parenta9b4bdf0bea8fe1b2be8f1839e95d7c0a5d012b1 (diff)
downloadplus-a1a00f0ed5366cfb8dbe448078ccc60331a0cdaa.tar.gz
plus-a1a00f0ed5366cfb8dbe448078ccc60331a0cdaa.tar.bz2
plus-a1a00f0ed5366cfb8dbe448078ccc60331a0cdaa.tar.xz
plus-a1a00f0ed5366cfb8dbe448078ccc60331a0cdaa.zip
improve a bit OpenGL drawing speed.
Diffstat (limited to 'src/mobileopenglgraphics.cpp')
-rw-r--r--src/mobileopenglgraphics.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/mobileopenglgraphics.cpp b/src/mobileopenglgraphics.cpp
index c53de9e0e..ee9761215 100644
--- a/src/mobileopenglgraphics.cpp
+++ b/src/mobileopenglgraphics.cpp
@@ -111,15 +111,13 @@ static inline void drawQuad(const Image *const image,
{
// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
{
+ const float tw = static_cast<float>(image->mTexWidth);
+ const float th = static_cast<float>(image->mTexHeight);
// Find OpenGL normalized texture coordinates.
- const float texX1 = static_cast<float>(srcX) /
- static_cast<float>(image->mTexWidth);
- const float texY1 = static_cast<float>(srcY) /
- static_cast<float>(image->mTexHeight);
- const float texX2 = static_cast<float>(srcX + width) /
- static_cast<float>(image->mTexWidth);
- const float texY2 = static_cast<float>(srcY + height) /
- static_cast<float>(image->mTexHeight);
+ const float texX1 = static_cast<float>(srcX) / tw;
+ const float texY1 = static_cast<float>(srcY) / th;
+ const float texX2 = static_cast<float>(srcX + width) / tw;
+ const float texY2 = static_cast<float>(srcY + height) / th;
GLfloat tex[] =
{
@@ -157,15 +155,13 @@ static inline void drawRescaledQuad(const Image *const image,
{
// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
{
+ const float tw = static_cast<float>(image->mTexWidth);
+ const float th = static_cast<float>(image->mTexHeight);
// Find OpenGL normalized texture coordinates.
- const float texX1 = static_cast<float>(srcX) /
- static_cast<float>(image->mTexWidth);
- const float texY1 = static_cast<float>(srcY) /
- static_cast<float>(image->mTexHeight);
- const float texX2 = static_cast<float>(srcX + width) /
- static_cast<float>(image->mTexWidth);
- const float texY2 = static_cast<float>(srcY + height) /
- static_cast<float>(image->mTexHeight);
+ const float texX1 = static_cast<float>(srcX) / tw;
+ const float texY1 = static_cast<float>(srcY) / th;
+ const float texX2 = static_cast<float>(srcX + width) / tw;
+ const float texY2 = static_cast<float>(srcY + height) / th;
GLfloat tex[] =
{
@@ -207,8 +203,6 @@ bool MobileOpenGLGraphics::drawImage2(const Image *const image,
return false;
const SDL_Rect &imageRect = image->mBounds;
- srcX += imageRect.x;
- srcY += imageRect.y;
if (!useColor)
setColorAlpha(image->mAlpha);
@@ -220,7 +214,8 @@ bool MobileOpenGLGraphics::drawImage2(const Image *const image,
setTexturingAndBlending(true);
- drawQuad(image, srcX, srcY, dstX, dstY, width, height);
+ drawQuad(image, srcX + imageRect.x, srcY + imageRect.y,
+ dstX, dstY, width, height);
return true;
}
@@ -923,7 +918,8 @@ SDL_Surface* MobileOpenGLGraphics::getScreenshot()
const unsigned int lineSize = 3 * w;
GLubyte *const buf = static_cast<GLubyte*>(malloc(lineSize));
- for (int i = 0; i < (h / 2); i++)
+ const int h2 = h / 2;
+ for (int i = 0; i < h2; i++)
{
GLubyte *const top = static_cast<GLubyte*>(
screenshot->pixels) + lineSize * i;