summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/being/compoundsprite.cpp4
-rw-r--r--src/graphicsmanager.cpp19
-rw-r--r--src/gui/debugwindow.cpp12
-rw-r--r--src/gui/sdlfont.cpp6
-rw-r--r--src/gui/sdlfont.h2
-rw-r--r--src/gui/widgets/desktop.cpp4
-rw-r--r--src/render/renderers.h33
-rw-r--r--src/resources/ambientlayer.cpp4
-rw-r--r--src/resources/image.cpp4
-rw-r--r--src/resources/imagehelper.h8
-rw-r--r--src/resources/openglimagehelper.cpp20
-rw-r--r--src/resources/openglimagehelper.h6
-rw-r--r--src/resources/sdl2imagehelper.cpp4
-rw-r--r--src/resources/sdl2imagehelper.h2
-rw-r--r--src/resources/sdlimagehelper.cpp4
-rw-r--r--src/resources/sdlimagehelper.h2
-rw-r--r--src/resources/surfaceimagehelper.cpp4
-rw-r--r--src/resources/surfaceimagehelper.h2
19 files changed, 93 insertions, 48 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7c90947af..860194517 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -680,6 +680,7 @@ SET(SRCS
notifymanager.h
render/nullopenglgraphics.cpp
render/nullopenglgraphics.h
+ render/renderers.h
particle/particle.cpp
particle/particle.h
particle/particlecontainer.cpp
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index 68a0d42e3..914afd1fe 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -398,7 +398,7 @@ void CompoundSprite::setAlpha(float alpha)
if (alpha != mAlpha)
{
#ifdef USE_OPENGL
- if (mEnableAlphaFix && imageHelper->useOpenGL() == 0
+ if (mEnableAlphaFix && imageHelper->useOpenGL() == RENDER_SOFTWARE
&& size() > 3)
#else
if (mEnableAlphaFix && size() > 3)
@@ -418,7 +418,7 @@ void CompoundSprite::updateImages() const
{
#ifndef USE_SDL2
#ifdef USE_OPENGL
- if (imageHelper->useOpenGL())
+ if (imageHelper->useOpenGL() != RENDER_SOFTWARE)
return;
#endif
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 0e88473f1..ba0a22d5d 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -42,6 +42,7 @@
#include "mgl.h"
#include "render/graphics.h"
+#include "render/renderers.h"
#include "render/sdlgraphics.h"
#include "resources/fboinfo.h"
@@ -219,9 +220,13 @@ int GraphicsManager::detectGraphics()
void GraphicsManager::initGraphics(const bool noOpenGL)
{
- int useOpenGL = 0;
+ RenderType useOpenGL = RENDER_SOFTWARE;
if (!noOpenGL)
- useOpenGL = config.getIntValue("opengl");
+ {
+ const int mode = config.getIntValue("opengl");
+ if (mode < RENDER_LAST && mode >= RENDER_SOFTWARE)
+ useOpenGL = static_cast<RenderType>(mode);
+ }
// Setup image loading for the right image format
OpenGLImageHelper::setLoadAsOpenGL(useOpenGL);
@@ -229,7 +234,7 @@ void GraphicsManager::initGraphics(const bool noOpenGL)
// Create the graphics context
switch (useOpenGL)
{
- case 0:
+ case RENDER_SOFTWARE:
imageHelper = new SDLImageHelper;
#ifdef USE_SDL2
surfaceImageHelper = new SurfaceImageHelper;
@@ -239,7 +244,7 @@ void GraphicsManager::initGraphics(const bool noOpenGL)
mainGraphics = new SDLGraphics;
mUseTextureSampler = false;
break;
- case 1:
+ case RENDER_NORMAL_OPENGL:
default:
#ifndef ANDROID
imageHelper = new OpenGLImageHelper;
@@ -247,21 +252,21 @@ void GraphicsManager::initGraphics(const bool noOpenGL)
mainGraphics = new NormalOpenGLGraphics;
mUseTextureSampler = true;
break;
- case 2:
+ case RENDER_SAFE_OPENGL:
imageHelper = new OpenGLImageHelper;
surfaceImageHelper = new SurfaceImageHelper;
mainGraphics = new SafeOpenGLGraphics;
mUseTextureSampler = false;
break;
#endif
- case 3:
+ case RENDER_GLES_OPENGL:
imageHelper = new OpenGLImageHelper;
surfaceImageHelper = new SurfaceImageHelper;
mainGraphics = new MobileOpenGLGraphics;
mUseTextureSampler = false;
break;
};
- mUseAtlases = imageHelper->useOpenGL()
+ mUseAtlases = imageHelper->useOpenGL() != RENDER_SOFTWARE
&& config.getBoolValue("useAtlases");
#else
void GraphicsManager::initGraphics(const bool noOpenGL A_UNUSED)
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 0d7dee0c2..4f3d22463 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -40,6 +40,8 @@
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/scrollarea.h"
+#include "render/renderers.h"
+
#include "resources/imagehelper.h"
#include "net/packetcounters.h"
@@ -202,20 +204,20 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
#ifdef USE_OPENGL
switch (imageHelper->useOpenGL())
{
- case 0:
+ case RENDER_SOFTWARE:
// TRANSLATORS: debug window label
mFPSText = _("%d FPS (Software)");
break;
- case 1:
+ case RENDER_NORMAL_OPENGL:
default:
// TRANSLATORS: debug window label
mFPSText = _("%d FPS (fast OpenGL)");
break;
- case 2:
+ case RENDER_SAFE_OPENGL:
// TRANSLATORS: debug window label
- mFPSText = _("%d FPS (old OpenGL)");
+ mFPSText = _("%d FPS (safe OpenGL)");
break;
- case 3:
+ case RENDER_GLES_OPENGL:
// TRANSLATORS: debug window label
mFPSText = _("%d FPS (mobile OpenGL)");
break;
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index c9093b747..54dbfbff6 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -48,7 +48,7 @@ const unsigned int CACHE_SIZE_SMALL3 = 170;
const unsigned int CLEAN_TIME = 7;
const int OUTLINE_SIZE = 1;
-bool SDLFont::mOpengl(true);
+bool SDLFont::mSoftMode(false);
char *strBuf;
@@ -99,7 +99,7 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const
if (c2.b != color2.b)
return c2.b > color2.b;
- if (c.a != color.a && !SDLFont::mOpengl)
+ if (c.a != color.a && SDLFont::mSoftMode)
return c.a > color.a;
return false;
@@ -347,7 +347,7 @@ SDLFont::SDLFont(std::string filename,
if (fontCounter == 0)
{
- mOpengl = imageHelper->useOpenGL();
+ mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE;
if (TTF_Init() == -1)
{
throw GCN_EXCEPTION("Unable to initialize SDL_ttf: " +
diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h
index 48e6c404f..29bf34769 100644
--- a/src/gui/sdlfont.h
+++ b/src/gui/sdlfont.h
@@ -147,7 +147,7 @@ class SDLFont final : public gcn::Font
int getDeleteCounter() const A_WARN_UNUSED
{ return mDeleteCounter; }
- static bool mOpengl;
+ static bool mSoftMode;
private:
TTF_Font *mFont;
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 0fd9fefef..93b0a96e7 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -100,7 +100,7 @@ void Desktop::draw(gcn::Graphics *graphics)
}
#ifndef USE_SDL2
- if (!imageHelper->useOpenGL())
+ if (imageHelper->useOpenGL() == RENDER_SOFTWARE)
{
g->drawImage(mWallpaper,
(width - wallpWidth) / 2,
@@ -153,7 +153,7 @@ void Desktop::setBestFittingWallpaper()
#ifdef USE_SDL2
if (false &&
#else
- if (!imageHelper->useOpenGL() &&
+ if (imageHelper->useOpenGL() == RENDER_SOFTWARE &&
#endif
(nWallPaper->getWidth() != width
|| nWallPaper->getHeight() != height))
diff --git a/src/render/renderers.h b/src/render/renderers.h
new file mode 100644
index 000000000..632614599
--- /dev/null
+++ b/src/render/renderers.h
@@ -0,0 +1,33 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2013 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RENDER_RENDERERS_H
+#define RENDER_RENDERERS_H
+
+enum RenderType
+{
+ RENDER_SOFTWARE = 0,
+ RENDER_NORMAL_OPENGL = 1,
+ RENDER_SAFE_OPENGL = 2,
+ RENDER_GLES_OPENGL = 3,
+ RENDER_LAST
+};
+
+#endif // RENDER_RENDERERS_H
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;