summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-01 23:49:05 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-01 23:49:05 +0300
commitd4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd (patch)
tree225407e8c57ad7d09335e9cf1d6985c0683f30a1
parent254cc9c7a5ecc45bb0c77b28d5e98e03674223f0 (diff)
downloadmv-d4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd.tar.gz
mv-d4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd.tar.bz2
mv-d4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd.tar.xz
mv-d4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd.zip
Move bindtexture in openglimagehelper into separate file.
-rw-r--r--src/resources/openglimagehelper.cpp48
-rw-r--r--src/resources/openglimagehelper.h2
2 files changed, 29 insertions, 21 deletions
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index 5f1ec643c..27d0e9956 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -193,27 +193,8 @@ SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
return tmpImage;
}
-Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
- int width, int height)
+void OpenGLImageHelper::bindTexture(const GLuint texture)
{
- if (!tmpImage)
- return nullptr;
-
- // Flush current error flag.
- graphicsManager.getLastError();
-
- if (!width)
- width = tmpImage->w;
- if (!height)
- height = tmpImage->h;
-
- SDL_Surface *oldImage = tmpImage;
- tmpImage = convertSurface(tmpImage, width, height);
-
- const int realWidth = tmpImage->w;
- const int realHeight = tmpImage->h;
-
- const GLuint texture = getNewTexture();
switch (mUseOpenGL)
{
#ifndef ANDROID
@@ -242,6 +223,30 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
logger->log("Unknown OpenGL backend: %d", mUseOpenGL);
break;
}
+}
+
+Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
+ int width, int height)
+{
+ if (!tmpImage)
+ return nullptr;
+
+ // Flush current error flag.
+ graphicsManager.getLastError();
+
+ if (!width)
+ width = tmpImage->w;
+ if (!height)
+ height = tmpImage->h;
+
+ SDL_Surface *oldImage = tmpImage;
+ tmpImage = convertSurface(tmpImage, width, height);
+
+ const int realWidth = tmpImage->w;
+ const int realHeight = tmpImage->h;
+
+ const GLuint texture = getNewTexture();
+ bindTexture(texture);
if (SDL_MUSTLOCK(tmpImage))
SDL_LockSurface(tmpImage);
@@ -377,12 +382,13 @@ void OpenGLImageHelper::copySurfaceToImage(Image *const image,
const int x, const int y,
SDL_Surface *surface) const
{
- if (!surface)
+ if (!surface || !image)
return;
SDL_Surface *const oldSurface = surface;
surface = convertSurface(surface, surface->w, surface->h);
+ bindTexture(image->mGLImage);
glTexSubImage2D(mTextureType, 0,
x, y,
surface->w, surface->h,
diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h
index b413e21ae..8d9560642 100644
--- a/src/resources/openglimagehelper.h
+++ b/src/resources/openglimagehelper.h
@@ -118,6 +118,8 @@ class OpenGLImageHelper final : public ImageHelper
static void invalidate(const GLuint textureId);
+ static void bindTexture(const GLuint texture);
+
SDL_Surface *create32BitSurface(int width,
int height) const override final;