diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-09-01 00:50:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-09-01 00:50:45 +0300 |
commit | af374aa2b2944749193af49cdca28532cf56fae2 (patch) | |
tree | b3e4fd2609a00175dbd94e42ab3d72984b4a051b /src/resources | |
parent | 00cda69b883d6354f093be6ee39a7936cb798979 (diff) | |
download | plus-af374aa2b2944749193af49cdca28532cf56fae2.tar.gz plus-af374aa2b2944749193af49cdca28532cf56fae2.tar.bz2 plus-af374aa2b2944749193af49cdca28532cf56fae2.tar.xz plus-af374aa2b2944749193af49cdca28532cf56fae2.zip |
add renderer enum.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/ambientlayer.cpp | 4 | ||||
-rw-r--r-- | src/resources/image.cpp | 4 | ||||
-rw-r--r-- | src/resources/imagehelper.h | 8 | ||||
-rw-r--r-- | src/resources/openglimagehelper.cpp | 20 | ||||
-rw-r--r-- | src/resources/openglimagehelper.h | 6 | ||||
-rw-r--r-- | src/resources/sdl2imagehelper.cpp | 4 | ||||
-rw-r--r-- | src/resources/sdl2imagehelper.h | 2 | ||||
-rw-r--r-- | src/resources/sdlimagehelper.cpp | 4 | ||||
-rw-r--r-- | src/resources/sdlimagehelper.h | 2 | ||||
-rw-r--r-- | src/resources/surfaceimagehelper.cpp | 4 | ||||
-rw-r--r-- | src/resources/surfaceimagehelper.h | 2 |
11 files changed, 32 insertions, 28 deletions
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index c619aafd9..6814b0365 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -40,7 +40,7 @@ AmbientLayer::AmbientLayer(Image *const img, const float parallax, if (!mImage) return; - if (keepRatio && !imageHelper->useOpenGL()) + if (keepRatio && imageHelper->useOpenGL() == RENDER_SOFTWARE) { const int width = mainGraphics->mWidth; const int height = mainGraphics->mHeight; @@ -108,7 +108,7 @@ void AmbientLayer::draw(Graphics *const graphics, const int x, if (!mImage) return; - if (!imageHelper->useOpenGL() || !mKeepRatio) + if (imageHelper->useOpenGL() == RENDER_SOFTWARE || !mKeepRatio) { graphics->drawImagePattern(mImage, static_cast<int>(-mPosX), static_cast<int>(-mPosY), x + static_cast<int>(mPosX), diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 1ed19629c..3d5d58620 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -244,7 +244,7 @@ bool Image::hasAlphaChannel() const return mHasAlphaChannel; #ifdef USE_OPENGL - if (OpenGLImageHelper::mUseOpenGL) + if (OpenGLImageHelper::mUseOpenGL != RENDER_SOFTWARE) return true; #endif @@ -413,7 +413,7 @@ Image *Image::getSubImage(const int x, const int y, { // Create a new clipped sub-image #ifdef USE_OPENGL - if (OpenGLImageHelper::mUseOpenGL) + if (OpenGLImageHelper::mUseOpenGL != RENDER_SOFTWARE) { return new SubImage(this, mGLImage, x, y, width, height, mTexWidth, mTexHeight); diff --git a/src/resources/imagehelper.h b/src/resources/imagehelper.h index 93c8784d5..b37d1e279 100644 --- a/src/resources/imagehelper.h +++ b/src/resources/imagehelper.h @@ -25,6 +25,8 @@ #include "localconsts.h" +#include "render/renderers.h" + #include "resources/resource.h" #include <SDL.h> @@ -71,7 +73,7 @@ class ImageHelper const int width, const int height, float alpha) const A_WARN_UNUSED = 0; - virtual int useOpenGL() const A_WARN_UNUSED = 0; + virtual RenderType useOpenGL() const A_WARN_UNUSED = 0; #else virtual Image *load(SDL_RWops *rw, Dye const &dye) const A_WARN_UNUSED { return nullptr; } @@ -83,8 +85,8 @@ class ImageHelper const float alpha) const A_WARN_UNUSED { return nullptr; } - virtual int useOpenGL() const A_WARN_UNUSED - { return 0; } + virtual RenderType useOpenGL() const A_WARN_UNUSED + { return RENDER_SOFTWARE; } #endif static SDL_Surface *convertTo32Bit(SDL_Surface *const tmpImage) diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp index 7fa779fa8..e686d6f5a 100644 --- a/src/resources/openglimagehelper.cpp +++ b/src/resources/openglimagehelper.cpp @@ -32,6 +32,7 @@ #include "render/mobileopenglgraphics.h" #include "render/normalopenglgraphics.h" +#include "render/renderers.h" #include "render/safeopenglgraphics.h" #include "resources/dye.h" @@ -49,7 +50,7 @@ int OpenGLImageHelper::mTextureType = 0; int OpenGLImageHelper::mInternalTextureType = GL_RGBA8; int OpenGLImageHelper::mTextureSize = 0; bool OpenGLImageHelper::mBlur = true; -int OpenGLImageHelper::mUseOpenGL = 0; +RenderType OpenGLImageHelper::mUseOpenGL = RENDER_SOFTWARE; bool OpenGLImageHelper::mUseTextureSampler = false; Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const @@ -200,19 +201,20 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, switch (mUseOpenGL) { #ifndef ANDROID - case 1: + case RENDER_NORMAL_OPENGL: NormalOpenGLGraphics::bindTexture(mTextureType, texture); break; - case 2: + case RENDER_SAFE_OPENGL: SafeOpenGLGraphics::bindTexture(mTextureType, texture); break; #else - case 1: - case 2: + case RENDER_NORMAL_OPENGL: + case RENDER_SAFE_OPENGL: #endif - case 3: + case RENDER_GLES_OPENGL: MobileOpenGLGraphics::bindTexture(mTextureType, texture); break; + case RENDER_SOFTWARE: default: logger->log("Unknown OpenGL backend: %d", mUseOpenGL); break; @@ -276,12 +278,12 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, return new Image(texture, width, height, realWidth, realHeight); } -void OpenGLImageHelper::setLoadAsOpenGL(const int useOpenGL) +void OpenGLImageHelper::setLoadAsOpenGL(const RenderType useOpenGL) { - OpenGLImageHelper::mUseOpenGL = useOpenGL; + mUseOpenGL = useOpenGL; } -int OpenGLImageHelper::useOpenGL() const +RenderType OpenGLImageHelper::useOpenGL() const { return mUseOpenGL; } diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h index 254edde9d..5ecf4512e 100644 --- a/src/resources/openglimagehelper.h +++ b/src/resources/openglimagehelper.h @@ -99,7 +99,7 @@ class OpenGLImageHelper final : public ImageHelper * Sets the target image format. Use <code>false</code> for SDL and * <code>true</code> for OpenGL. */ - static void setLoadAsOpenGL(const int useOpenGL); + static void setLoadAsOpenGL(const RenderType useOpenGL); static int getTextureType() A_WARN_UNUSED { return mTextureType; } @@ -121,7 +121,7 @@ class OpenGLImageHelper final : public ImageHelper * Tells if the image was loaded using OpenGL or SDL * @return true if OpenGL, false if SDL. */ - int useOpenGL() const override A_WARN_UNUSED; + RenderType useOpenGL() const override A_WARN_UNUSED; static int getTextureSize() A_WARN_UNUSED { return mTextureSize; } @@ -142,7 +142,7 @@ class OpenGLImageHelper final : public ImageHelper Image *glLoad(SDL_Surface *tmpImage, int width = 0, int height = 0) const A_WARN_UNUSED; - static int mUseOpenGL; + static RenderType mUseOpenGL; static int mTextureSize; static bool mBlur; static bool mUseTextureSampler; diff --git a/src/resources/sdl2imagehelper.cpp b/src/resources/sdl2imagehelper.cpp index 65ce5fb8d..eedb58de3 100644 --- a/src/resources/sdl2imagehelper.cpp +++ b/src/resources/sdl2imagehelper.cpp @@ -146,9 +146,9 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const return new Image(texture, tmpImage->w, tmpImage->h); } -int SDLImageHelper::useOpenGL() const +RenderType SDLImageHelper::useOpenGL() const { - return 0; + return RENDER_SOFTWARE; } SDL_Surface *SDLImageHelper::create32BitSurface(int width, int height) const diff --git a/src/resources/sdl2imagehelper.h b/src/resources/sdl2imagehelper.h index 5c35f8026..e0e0d0e9e 100644 --- a/src/resources/sdl2imagehelper.h +++ b/src/resources/sdl2imagehelper.h @@ -82,7 +82,7 @@ class SDLImageHelper final : public ImageHelper * Tells if the image was loaded using OpenGL or SDL * @return true if OpenGL, false if SDL. */ - int useOpenGL() const override A_WARN_UNUSED; + RenderType useOpenGL() const override A_WARN_UNUSED; static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage) A_WARN_UNUSED; diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp index e7d7bacd6..9742bbd5d 100644 --- a/src/resources/sdlimagehelper.cpp +++ b/src/resources/sdlimagehelper.cpp @@ -276,9 +276,9 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const return new Image(image, hasAlpha, alphaChannel); } -int SDLImageHelper::useOpenGL() const +RenderType SDLImageHelper::useOpenGL() const { - return 0; + return RENDER_SOFTWARE; } SDL_Surface *SDLImageHelper::create32BitSurface(int width, int height) const diff --git a/src/resources/sdlimagehelper.h b/src/resources/sdlimagehelper.h index 6f53c75ef..7d98e7fc4 100644 --- a/src/resources/sdlimagehelper.h +++ b/src/resources/sdlimagehelper.h @@ -85,7 +85,7 @@ class SDLImageHelper final : public ImageHelper * Tells if the image was loaded using OpenGL or SDL * @return true if OpenGL, false if SDL. */ - int useOpenGL() const override A_WARN_UNUSED; + RenderType useOpenGL() const override A_WARN_UNUSED; static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage) A_WARN_UNUSED; diff --git a/src/resources/surfaceimagehelper.cpp b/src/resources/surfaceimagehelper.cpp index 44cee32d9..b249dfea9 100644 --- a/src/resources/surfaceimagehelper.cpp +++ b/src/resources/surfaceimagehelper.cpp @@ -144,9 +144,9 @@ Image *SurfaceImageHelper::_SDLload(SDL_Surface *tmpImage) const return new Image(image, false, nullptr); } -int SurfaceImageHelper::useOpenGL() const +RenderType SurfaceImageHelper::useOpenGL() const { - return 0; + return RENDER_SOFTWARE; } SDL_Surface *SurfaceImageHelper::create32BitSurface(int width, diff --git a/src/resources/surfaceimagehelper.h b/src/resources/surfaceimagehelper.h index afc80cbbb..1a1a03d5a 100644 --- a/src/resources/surfaceimagehelper.h +++ b/src/resources/surfaceimagehelper.h @@ -85,7 +85,7 @@ class SurfaceImageHelper final : public ImageHelper * Tells if the image was loaded using OpenGL or SDL * @return true if OpenGL, false if SDL. */ - int useOpenGL() const override A_WARN_UNUSED; + RenderType useOpenGL() const override A_WARN_UNUSED; static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage) A_WARN_UNUSED; |