diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-01 23:49:05 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-01 23:49:05 +0300 |
commit | d4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd (patch) | |
tree | 225407e8c57ad7d09335e9cf1d6985c0683f30a1 /src/resources/openglimagehelper.cpp | |
parent | 254cc9c7a5ecc45bb0c77b28d5e98e03674223f0 (diff) | |
download | mv-d4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd.tar.gz mv-d4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd.tar.bz2 mv-d4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd.tar.xz mv-d4464b7c70f7d969a39d0a0e20b1e8d1ccebefcd.zip |
Move bindtexture in openglimagehelper into separate file.
Diffstat (limited to 'src/resources/openglimagehelper.cpp')
-rw-r--r-- | src/resources/openglimagehelper.cpp | 48 |
1 files changed, 27 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, |