summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client.cpp4
-rw-r--r--src/graphicsmanager.cpp45
-rw-r--r--src/gui/widgets/colormodel.h2
-rw-r--r--src/gui/widgets/textfield.cpp1
-rw-r--r--src/input/keyevent.h4
-rw-r--r--src/input/keyinput.h4
-rw-r--r--src/resources/image.cpp4
-rw-r--r--src/resources/imagehelper.cpp1
-rw-r--r--src/resources/imagehelper.h12
-rw-r--r--src/resources/openglimagehelper.cpp11
-rw-r--r--src/resources/openglimagehelper.h13
-rw-r--r--src/resources/sdl2imagehelper.cpp5
-rw-r--r--src/resources/sdl2imagehelper.h6
-rw-r--r--src/resources/sdl2softwareimagehelper.cpp5
-rw-r--r--src/resources/sdl2softwareimagehelper.h6
-rw-r--r--src/resources/sdlimagehelper.cpp5
-rw-r--r--src/resources/sdlimagehelper.h6
17 files changed, 61 insertions, 73 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 7ab7cb328..fcfb6db7f 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2357,11 +2357,7 @@ void Client::storeSafeParameters() const
if (isSafeMode)
logger->log1("Run in safe mode");
-#if defined USE_OPENGL
tmpOpengl = intToRenderType(config.getIntValue("opengl"));
-#else
- tmpOpengl = RENDER_SOFTWARE;
-#endif
width = config.getIntValue("screenwidth");
height = config.getIntValue("screenheight");
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index ecc05cd4f..73ed3d88a 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -232,7 +232,7 @@ void GraphicsManager::initGraphics(const bool noOpenGL)
useOpenGL = intToRenderType(config.getIntValue("opengl"));
// Setup image loading for the right image format
- OpenGLImageHelper::setLoadAsOpenGL(useOpenGL);
+ ImageHelper::setOpenGlMode(useOpenGL);
// Create the graphics context
switch (useOpenGL)
@@ -286,18 +286,51 @@ void GraphicsManager::initGraphics(const bool noOpenGL)
mUseAtlases = (useOpenGL == RENDER_NORMAL_OPENGL
|| useOpenGL == RENDER_SAFE_OPENGL || useOpenGL == RENDER_GLES_OPENGL)
&& config.getBoolValue("useAtlases");
-#else
+
+#else // USE_OPENGL
+
void GraphicsManager::initGraphics(const bool noOpenGL A_UNUSED)
{
+ RenderType useOpenGL = RENDER_SOFTWARE;
+ if (!noOpenGL)
+ useOpenGL = intToRenderType(config.getIntValue("opengl"));
+
+ // Setup image loading for the right image format
+ ImageHelper::setOpenGlMode(useOpenGL);
+
// Create the graphics context
- imageHelper = new SDLImageHelper;
+ switch (useOpenGL)
+ {
+ case RENDER_SOFTWARE:
+ case RENDER_SAFE_OPENGL:
+ case RENDER_GLES_OPENGL:
+ case RENDER_NORMAL_OPENGL:
+ default:
+#ifndef USE_SDL2
+ case RENDER_SDL2_DEFAULT:
+#endif
#ifdef USE_SDL2
- surfaceImageHelper = new SurfaceImageHelper;
+ imageHelper = new SDL2SoftwareImageHelper;
+ surfaceImageHelper = new SurfaceImageHelper;
+ mainGraphics = new SDL2SoftwareGraphics;
#else
- surfaceImageHelper = imageHelper;
+ imageHelper = new SDLImageHelper;
+ surfaceImageHelper = imageHelper;
+ mainGraphics = new SDLGraphics;
#endif
- mainGraphics = new SDLGraphics;
+ break;
+#ifdef USE_SDL2
+ case RENDER_SDL2_DEFAULT:
+ imageHelper = new SDLImageHelper;
+ surfaceImageHelper = new SurfaceImageHelper;
+ mainGraphics = new SDLGraphics;
+ mainGraphics->setRendererFlags(SDL_RENDERER_ACCELERATED);
+ break;
#endif
+ };
+
+#endif // USE_OPENGL
+
}
void GraphicsManager::setVideoMode()
diff --git a/src/gui/widgets/colormodel.h b/src/gui/widgets/colormodel.h
index 64310958d..5ce7629a4 100644
--- a/src/gui/widgets/colormodel.h
+++ b/src/gui/widgets/colormodel.h
@@ -26,6 +26,8 @@
#include <guichan/color.hpp>
#include <guichan/listmodel.hpp>
+#include "localconsts.h"
+
class Widget2;
struct ColorPair
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index d6bc9ca68..022a20781 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -28,6 +28,7 @@
#include "input/keyevent.h"
#include "gui/popupmenu.h"
+#include "gui/sdlinput.h"
#include "gui/viewport.h"
#include "resources/image.h"
diff --git a/src/input/keyevent.h b/src/input/keyevent.h
index cb96f45c9..eaed82376 100644
--- a/src/input/keyevent.h
+++ b/src/input/keyevent.h
@@ -24,6 +24,10 @@
#include <guichan/key.hpp>
#include <guichan/keyevent.hpp>
+#include <string>
+
+#include "localconsts.h"
+
class KeyEvent final : public gcn::KeyEvent
{
public:
diff --git a/src/input/keyinput.h b/src/input/keyinput.h
index 9d744f01c..24545ed1d 100644
--- a/src/input/keyinput.h
+++ b/src/input/keyinput.h
@@ -23,6 +23,10 @@
#include <guichan/keyinput.hpp>
+#include <string>
+
+#include "localconsts.h"
+
class KeyInput final : public gcn::KeyInput
{
public:
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 1a327eae1..4cb9d7f1d 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -419,7 +419,9 @@ Image *Image::getSubImage(const int x, const int y,
#endif
#ifdef USE_SDL2
- // +++ probably default sdl render is broken here
+#ifndef USE_OPENGL
+ const RenderType mode = ImageHelper::mUseOpenGL;
+#endif
if (mode == RENDER_SOFTWARE)
return new SubImage(this, mSDLSurface, x, y, width, height);
else
diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp
index 8a97b4a81..c94016ca1 100644
--- a/src/resources/imagehelper.cpp
+++ b/src/resources/imagehelper.cpp
@@ -41,6 +41,7 @@ ImageHelper *imageHelper = nullptr;
ImageHelper *surfaceImageHelper = nullptr;
bool ImageHelper::mEnableAlpha = true;
+RenderType ImageHelper::mUseOpenGL = RENDER_SOFTWARE;
Image *ImageHelper::load(SDL_RWops *const rw) const
{
diff --git a/src/resources/imagehelper.h b/src/resources/imagehelper.h
index b37d1e279..ed8f89323 100644
--- a/src/resources/imagehelper.h
+++ b/src/resources/imagehelper.h
@@ -72,8 +72,6 @@ class ImageHelper
virtual Image *createTextSurface(SDL_Surface *const tmpImage,
const int width, const int height,
float alpha) 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; }
@@ -84,9 +82,6 @@ class ImageHelper
virtual Image *createTextSurface(SDL_Surface *const tmpImage,
const float alpha) const A_WARN_UNUSED
{ return nullptr; }
-
- virtual RenderType useOpenGL() const A_WARN_UNUSED
- { return RENDER_SOFTWARE; }
#endif
static SDL_Surface *convertTo32Bit(SDL_Surface *const tmpImage)
@@ -102,8 +97,15 @@ class ImageHelper
static SDL_Surface *loadPng(SDL_RWops *const rw);
+ static void setOpenGlMode(const RenderType useOpenGL)
+ { mUseOpenGL = useOpenGL; }
+
+ virtual RenderType useOpenGL() const A_WARN_UNUSED
+ { return mUseOpenGL; }
+
protected:
static bool mEnableAlpha;
+ static RenderType mUseOpenGL;
};
extern ImageHelper *imageHelper;
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index c41538b2e..014c33362 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -50,7 +50,6 @@ int OpenGLImageHelper::mTextureType = 0;
int OpenGLImageHelper::mInternalTextureType = GL_RGBA8;
int OpenGLImageHelper::mTextureSize = 0;
bool OpenGLImageHelper::mBlur = true;
-RenderType OpenGLImageHelper::mUseOpenGL = RENDER_SOFTWARE;
bool OpenGLImageHelper::mUseTextureSampler = false;
Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const
@@ -279,16 +278,6 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
return new Image(texture, width, height, realWidth, realHeight);
}
-void OpenGLImageHelper::setLoadAsOpenGL(const RenderType useOpenGL)
-{
- mUseOpenGL = useOpenGL;
-}
-
-RenderType OpenGLImageHelper::useOpenGL() const
-{
- return mUseOpenGL;
-}
-
void OpenGLImageHelper::initTextureSampler(const GLint id)
{
if (mBlur)
diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h
index 5ecf4512e..b8437e1aa 100644
--- a/src/resources/openglimagehelper.h
+++ b/src/resources/openglimagehelper.h
@@ -95,12 +95,6 @@ class OpenGLImageHelper final : public ImageHelper
// OpenGL only public functions
- /**
- * Sets the target image format. Use <code>false</code> for SDL and
- * <code>true</code> for OpenGL.
- */
- static void setLoadAsOpenGL(const RenderType useOpenGL);
-
static int getTextureType() A_WARN_UNUSED
{ return mTextureType; }
@@ -117,12 +111,6 @@ class OpenGLImageHelper final : public ImageHelper
static int mInternalTextureType;
- /**
- * Tells if the image was loaded using OpenGL or SDL
- * @return true if OpenGL, false if SDL.
- */
- RenderType useOpenGL() const override A_WARN_UNUSED;
-
static int getTextureSize() A_WARN_UNUSED
{ return mTextureSize; }
@@ -142,7 +130,6 @@ class OpenGLImageHelper final : public ImageHelper
Image *glLoad(SDL_Surface *tmpImage,
int width = 0, int height = 0) const A_WARN_UNUSED;
- 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 0433d2595..2ee72b0ee 100644
--- a/src/resources/sdl2imagehelper.cpp
+++ b/src/resources/sdl2imagehelper.cpp
@@ -146,11 +146,6 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const
return new Image(texture, tmpImage->w, tmpImage->h);
}
-RenderType SDLImageHelper::useOpenGL() const
-{
- return RENDER_SDL2_DEFAULT;
-}
-
SDL_Surface *SDLImageHelper::create32BitSurface(int width, int height) const
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
diff --git a/src/resources/sdl2imagehelper.h b/src/resources/sdl2imagehelper.h
index e0e0d0e9e..1790484e3 100644
--- a/src/resources/sdl2imagehelper.h
+++ b/src/resources/sdl2imagehelper.h
@@ -78,12 +78,6 @@ class SDLImageHelper final : public ImageHelper
static bool SDLGetEnableAlphaCache() A_WARN_UNUSED
{ return mEnableAlphaCache; }
- /**
- * Tells if the image was loaded using OpenGL or SDL
- * @return true if OpenGL, false if SDL.
- */
- RenderType useOpenGL() const override A_WARN_UNUSED;
-
static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
A_WARN_UNUSED;
diff --git a/src/resources/sdl2softwareimagehelper.cpp b/src/resources/sdl2softwareimagehelper.cpp
index 7c4ff3d5d..db41a4ddc 100644
--- a/src/resources/sdl2softwareimagehelper.cpp
+++ b/src/resources/sdl2softwareimagehelper.cpp
@@ -141,11 +141,6 @@ Image *SDL2SoftwareImageHelper::_SDLload(SDL_Surface *tmpImage) const
return new Image(image, false, nullptr);
}
-RenderType SDL2SoftwareImageHelper::useOpenGL() const
-{
- return RENDER_SOFTWARE;
-}
-
SDL_Surface *SDL2SoftwareImageHelper::create32BitSurface(int width,
int height) const
{
diff --git a/src/resources/sdl2softwareimagehelper.h b/src/resources/sdl2softwareimagehelper.h
index 99a1a67e9..2eda73aa5 100644
--- a/src/resources/sdl2softwareimagehelper.h
+++ b/src/resources/sdl2softwareimagehelper.h
@@ -78,12 +78,6 @@ class SDL2SoftwareImageHelper final : public ImageHelper
static bool SDLGetEnableAlphaCache() A_WARN_UNUSED
{ return mEnableAlphaCache; }
- /**
- * Tells if the image was loaded using OpenGL or SDL
- * @return true if OpenGL, false if SDL.
- */
- 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 9742bbd5d..ad146aa22 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -276,11 +276,6 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const
return new Image(image, hasAlpha, alphaChannel);
}
-RenderType SDLImageHelper::useOpenGL() const
-{
- return RENDER_SOFTWARE;
-}
-
SDL_Surface *SDLImageHelper::create32BitSurface(int width, int height) const
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
diff --git a/src/resources/sdlimagehelper.h b/src/resources/sdlimagehelper.h
index 7d98e7fc4..5c3cabb09 100644
--- a/src/resources/sdlimagehelper.h
+++ b/src/resources/sdlimagehelper.h
@@ -81,12 +81,6 @@ class SDLImageHelper final : public ImageHelper
static bool SDLGetEnableAlphaCache() A_WARN_UNUSED
{ return mEnableAlphaCache; }
- /**
- * Tells if the image was loaded using OpenGL or SDL
- * @return true if OpenGL, false if SDL.
- */
- RenderType useOpenGL() const override A_WARN_UNUSED;
-
static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
A_WARN_UNUSED;