summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-09-01 14:41:34 +0300
committerAndrei Karas <akaras@inbox.ru>2013-09-01 14:53:49 +0300
commit222748a7e0c79225c66485898b913aa60f56cfe2 (patch)
tree38e27f08cec39bf8cca26df8caade81c112245e8 /src
parentf4df2a0fd2d9c01b6f756c4b00ed9848f319a1b0 (diff)
downloadmv-222748a7e0c79225c66485898b913aa60f56cfe2.tar.gz
mv-222748a7e0c79225c66485898b913aa60f56cfe2.tar.bz2
mv-222748a7e0c79225c66485898b913aa60f56cfe2.tar.xz
mv-222748a7e0c79225c66485898b913aa60f56cfe2.zip
add way to map render mode selection to actual modes.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am3
-rw-r--r--src/client.cpp14
-rw-r--r--src/graphicsmanager.cpp6
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/setup_video.cpp62
-rw-r--r--src/gui/setup_video.h2
-rw-r--r--src/gui/widgets/widget2.h5
-rw-r--r--src/map.cpp4
-rw-r--r--src/map.h4
-rw-r--r--src/render/renderers.cpp38
-rw-r--r--src/render/renderers.h6
-rw-r--r--src/render/rendererslist.h115
13 files changed, 201 insertions, 62 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 860194517..5c61747fe 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -680,7 +680,9 @@ SET(SRCS
notifymanager.h
render/nullopenglgraphics.cpp
render/nullopenglgraphics.h
+ render/renderers.cpp
render/renderers.h
+ render/rendererslist.h
particle/particle.cpp
particle/particle.h
particle/particlecontainer.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 302194821..4e9dec8bb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -689,6 +689,9 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
notifymanager.h \
render/nullopenglgraphics.cpp \
render/nullopenglgraphics.h \
+ render/renderers.cpp \
+ render/renderers.h \
+ render/rendererslist.h \
particle/particle.cpp \
particle/particle.h \
particle/particlecontainer.cpp \
diff --git a/src/client.cpp b/src/client.cpp
index 1dcdcfec3..fef14b6e6 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -169,7 +169,7 @@ UserPalette *userPalette = nullptr;
Graphics *mainGraphics = nullptr;
SoundManager soundManager;
-int openGLMode = 0;
+RenderType openGLMode = RENDER_SOFTWARE;
static uint32_t nextTick(uint32_t interval, void *param A_UNUSED);
static uint32_t nextSecond(uint32_t interval, void *param A_UNUSED);
@@ -573,14 +573,14 @@ void Client::gameInit()
#endif
#ifdef USE_OPENGL
- openGLMode = config.getIntValue("opengl");
+ openGLMode = intToRenderType(config.getIntValue("opengl"));
OpenGLImageHelper::setBlur(config.getBoolValue("blur"));
SurfaceImageHelper::SDLSetEnableAlphaCache(
config.getBoolValue("alphaCache") && !openGLMode);
ImageHelper::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f
|| openGLMode);
#else
- openGLMode = 0;
+ openGLMode = RENDER_SOFTWARE;
SurfaceImageHelper::SDLSetEnableAlphaCache(
config.getBoolValue("alphaCache"));
ImageHelper::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f);
@@ -2339,7 +2339,7 @@ void Client::accountLogin(LoginData *const data) const
void Client::storeSafeParameters() const
{
bool tmpHwaccel;
- int tmpOpengl;
+ RenderType tmpOpengl;
int tmpFpslimit;
int tmpAltFpslimit;
bool tmpSound;
@@ -2360,7 +2360,7 @@ void Client::storeSafeParameters() const
logger->log1("Run in safe mode");
#if defined USE_OPENGL
- tmpOpengl = config.getIntValue("opengl");
+ tmpOpengl = intToRenderType(config.getIntValue("opengl"));
#else
tmpOpengl = 0;
#endif
@@ -2440,7 +2440,7 @@ void Client::storeSafeParameters() const
if (!tmpOpengl)
{
config.setValue("hwaccel", tmpHwaccel);
- config.setValue("opengl", tmpOpengl);
+ config.setValue("opengl", static_cast<int>(tmpOpengl));
config.setValue("fpslimit", tmpFpslimit);
config.setValue("altfpslimit", tmpAltFpslimit);
config.setValue("sound", tmpSound);
@@ -2459,7 +2459,7 @@ void Client::storeSafeParameters() const
}
else
{
- config.setValue("opengl", tmpOpengl);
+ config.setValue("opengl", static_cast<int>(tmpOpengl));
config.setValue("screenwidth", width);
config.setValue("screenheight", height);
}
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index ba0a22d5d..5304c69c5 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -222,11 +222,7 @@ void GraphicsManager::initGraphics(const bool noOpenGL)
{
RenderType useOpenGL = RENDER_SOFTWARE;
if (!noOpenGL)
- {
- const int mode = config.getIntValue("opengl");
- if (mode < RENDER_LAST && mode >= RENDER_SOFTWARE)
- useOpenGL = static_cast<RenderType>(mode);
- }
+ useOpenGL = intToRenderType(config.getIntValue("opengl"));
// Setup image loading for the right image format
OpenGLImageHelper::setLoadAsOpenGL(useOpenGL);
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 4f3d22463..fdd68092a 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -40,8 +40,6 @@
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/scrollarea.h"
-#include "render/renderers.h"
-
#include "resources/imagehelper.h"
#include "net/packetcounters.h"
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 594d5ff4d..f9a7535d0 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -45,6 +45,7 @@
#include "gui/widgets/textfield.h"
#include "gui/widgets/dropdown.h"
+#include "render/rendererslist.h"
#include "resources/image.h"
#include "utils/gettext.h"
@@ -164,20 +165,6 @@ int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
return -1;
}
-const char *OPENGL_NAME[4] =
-{
- // TRANSLATORS: draw backend
- N_("Software"),
-#ifndef ANDROID
- // TRANSLATORS: draw backend
- N_("Fast OpenGL"),
- // TRANSLATORS: draw backend
- N_("Safe OpenGL"),
-#endif
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL"),
-};
-
class OpenGLListModel final : public gcn::ListModel
{
public:
@@ -185,11 +172,7 @@ public:
{ }
virtual int getNumberOfElements() override
-#ifdef ANDROID
- { return 2; }
-#else
- { return 4; }
-#endif
+ { return renderModesListSize; }
virtual std::string getElementAt(int i) override
{
@@ -203,7 +186,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
SetupTab(widget),
gcn::KeyListener(),
mFullScreenEnabled(config.getBoolValue("screen")),
- mOpenGLEnabled(config.getIntValue("opengl")),
+ mOpenGLEnabled(intToRenderType(config.getIntValue("opengl"))),
mFps(config.getIntValue("fpslimit")),
mAltFps(config.getIntValue("altfpslimit")),
mModeListModel(new ModeListModel),
@@ -250,15 +233,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
scrollArea->setWidth(150);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
-#ifdef USE_OPENGL
-#ifdef ANDROID
- if (mOpenGLEnabled == 1 || mOpenGLEnabled == 2)
- mOpenGLEnabled = 3;
-#endif
- mOpenGLDropDown->setSelected(mOpenGLEnabled);
-#else
- mOpenGLDropDown->setSelected(0);
-#endif
+ mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]);
mModeList->setEnabled(true);
@@ -362,7 +337,7 @@ void Setup_Video::apply()
#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
// checks for opengl usage
- if (!config.getIntValue("opengl"))
+ if (intToRenderType(config.getIntValue("opengl")) == RENDER_SOFTWARE)
{
#endif
if (!mainGraphics->setFullscreen(fullscreen))
@@ -401,16 +376,15 @@ void Setup_Video::apply()
config.setValue("screen", fullscreen);
}
- int mode = mOpenGLDropDown->getSelected();
-#ifdef ANDROID
- if (mode == 1 || mode == 2)
- mode = 3;
-#endif
+ const int sel = mOpenGLDropDown->getSelected();
+ RenderType mode = RENDER_SOFTWARE;
+ if (sel >= 0 && static_cast<unsigned int>(sel) < sizeof(indexToRender))
+ mode = indexToRender[mOpenGLDropDown->getSelected()];
// OpenGL change
if (mode != mOpenGLEnabled)
{
- config.setValue("opengl", mode);
+ config.setValue("opengl", static_cast<int>(mode));
// OpenGL can currently only be changed by restarting, notify user.
// TRANSLATORS: video settings warning
@@ -436,7 +410,7 @@ void Setup_Video::apply()
mFullScreenEnabled = config.getBoolValue("screen");
mCustomCursorEnabled = config.getBoolValue("customcursor");
- mOpenGLEnabled = config.getIntValue("opengl");
+ mOpenGLEnabled = intToRenderType(config.getIntValue("opengl"));
mEnableResize = config.getBoolValue("enableresize");
mNoFrame = config.getBoolValue("noframe");
}
@@ -445,7 +419,7 @@ void Setup_Video::cancel()
{
mFpsCheckBox->setSelected(mFps > 0);
mFsCheckBox->setSelected(mFullScreenEnabled);
- mOpenGLDropDown->setSelected(mOpenGLEnabled);
+ mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]);
mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
mFpsSlider->setValue(mFps);
mFpsSlider->setEnabled(mFps > 0);
@@ -469,7 +443,7 @@ void Setup_Video::cancel()
config.setValue("screenheight", mainGraphics->mHeight);
config.setValue("customcursor", mCustomCursorEnabled);
- config.setValue("opengl", mOpenGLEnabled);
+ config.setValue("opengl", static_cast<int>(mOpenGLEnabled));
config.setValue("enableresize", mEnableResize);
config.setValue("noframe", mNoFrame);
}
@@ -510,7 +484,8 @@ void Setup_Video::action(const gcn::ActionEvent &event)
if (width != mainGraphics->mWidth || height != mainGraphics->mHeight)
{
#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
- if (!config.getIntValue("opengl"))
+ if (intToRenderType(config.getIntValue("opengl"))
+ == RENDER_SOFTWARE)
{
client->resizeVideo(width, height);
}
@@ -598,8 +573,11 @@ void Setup_Video::action(const gcn::ActionEvent &event)
if (test)
{
const int val = test->getConfig().getValueInt("opengl", -1);
- if (val >= 0 && val <= 3)
- mOpenGLDropDown->setSelected(val);
+ if (val >= 0 && static_cast<unsigned int>(val)
+ < sizeof(renderToIndex))
+ {
+ mOpenGLDropDown->setSelected(renderToIndex[val]);
+ }
delete test;
}
}
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 7974e8e3d..b7c54e2af 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -56,7 +56,7 @@ class Setup_Video final : public SetupTab, public gcn::KeyListener
private:
bool mFullScreenEnabled;
- int mOpenGLEnabled;
+ RenderType mOpenGLEnabled;
int mFps;
int mAltFps;
ModeListModel *mModeListModel;
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index 94cc7760e..9e164046b 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -21,9 +21,10 @@
#ifndef GUI_WIDGETS_WIDGET2_H
#define GUI_WIDGETS_WIDGET2_H
+#include "gui/gui.h"
#include "gui/theme.h"
-#include "gui/gui.h"
+#include "render/renderers.h"
class Widget2
{
@@ -94,6 +95,6 @@ class Widget2
gcn::Color mForegroundColor2;
};
-extern int openGLMode;
+extern RenderType openGLMode;
#endif // GUI_WIDGETS_WIDGET2_H
diff --git a/src/map.cpp b/src/map.cpp
index 189981f80..388f2eccf 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -148,9 +148,9 @@ Map::Map(const int width, const int height,
mOverlayDetail(config.getIntValue("OverlayDetail")),
mOpacity(config.getFloatValue("guialpha")),
#ifdef USE_OPENGL
- mOpenGL(config.getIntValue("opengl")),
+ mOpenGL(intToRenderType(config.getIntValue("opengl"))),
#else
- mOpenGL(0),
+ mOpenGL(RENDER_SOFTWARE),
#endif
mPvp(0),
mTilesetsIndexed(false),
diff --git a/src/map.h b/src/map.h
index 2a954b7c4..41fc28185 100644
--- a/src/map.h
+++ b/src/map.h
@@ -29,6 +29,8 @@
#include "being/actor.h"
+#include "render/renderers.h"
+
#include <string>
#include <vector>
@@ -509,7 +511,7 @@ class Map final : public Properties, public ConfigListener
int mOverlayDetail;
float mOpacity;
- int mOpenGL;
+ RenderType mOpenGL;
int mPvp;
bool mTilesetsIndexed;
Tileset** mIndexedTilesets;
diff --git a/src/render/renderers.cpp b/src/render/renderers.cpp
new file mode 100644
index 000000000..97364f54a
--- /dev/null
+++ b/src/render/renderers.cpp
@@ -0,0 +1,38 @@
+/*
+ * 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/>.
+ */
+
+#include "render/renderers.h"
+
+RenderType intToRenderType(const int mode)
+{
+ if (mode < 0 || mode > RENDER_LAST)
+ {
+#ifdef USE_OPENGL
+#ifdef ANDROID
+ return RENDER_GLES_OPENGL;
+#else
+ return RENDER_NORMAL_OPENGL;
+#endif
+#else
+ return RENDER_SOFTWARE;
+#endif
+ }
+ return static_cast<RenderType>(mode);
+}
diff --git a/src/render/renderers.h b/src/render/renderers.h
index 632614599..8922f3d10 100644
--- a/src/render/renderers.h
+++ b/src/render/renderers.h
@@ -21,13 +21,19 @@
#ifndef RENDER_RENDERERS_H
#define RENDER_RENDERERS_H
+#include "utils/gettext.h"
+
enum RenderType
{
RENDER_SOFTWARE = 0,
+#ifdef USE_OPENGL
RENDER_NORMAL_OPENGL = 1,
RENDER_SAFE_OPENGL = 2,
RENDER_GLES_OPENGL = 3,
+#endif
RENDER_LAST
};
+RenderType intToRenderType(const int mode);
+
#endif // RENDER_RENDERERS_H
diff --git a/src/render/rendererslist.h b/src/render/rendererslist.h
new file mode 100644
index 000000000..6c4e3fd0e
--- /dev/null
+++ b/src/render/rendererslist.h
@@ -0,0 +1,115 @@
+/*
+ * 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/>.
+ */
+
+#include "utils/gettext.h"
+
+#ifndef RENDER_RENDERERSLIST_H
+#define RENDER_RENDERERSLIST_H
+
+#ifdef USE_OPENGL
+#ifdef ANDROID
+
+// map for index to RenderType
+const RenderType indexToRender[] =
+{
+ RENDER_SOFTWARE,
+ RENDER_GLES_OPENGL,
+};
+
+const char *OPENGL_NAME[] =
+{
+ // TRANSLATORS: draw backend
+ N_("Software"),
+ // TRANSLATORS: draw backend
+ N_("Mobile OpenGL"),
+};
+
+const int renderModesListSize = 2;
+
+const int renderToIndex[] =
+{
+ 0, // RENDER_SOFTWARE
+ 3, // RENDER_GLES_OPENGL
+ 3, // RENDER_GLES_OPENGL
+ 3 // RENDER_GLES_OPENGL
+};
+
+#else // ANDROID
+
+// map for index to RenderType
+const RenderType indexToRender[] =
+{
+ RENDER_SOFTWARE,
+ RENDER_NORMAL_OPENGL,
+ RENDER_SAFE_OPENGL,
+ RENDER_GLES_OPENGL,
+};
+
+const char *OPENGL_NAME[] =
+{
+ // TRANSLATORS: draw backend
+ N_("Software"),
+ // TRANSLATORS: draw backend
+ N_("Fast OpenGL"),
+ // TRANSLATORS: draw backend
+ N_("Safe OpenGL"),
+ // TRANSLATORS: draw backend
+ N_("Mobile OpenGL"),
+};
+
+const int renderModesListSize = 4;
+
+const int renderToIndex[] =
+{
+ 0, // RENDER_SOFTWARE
+ 1, // RENDER_NORMAL_OPENGL
+ 2, // RENDER_SAFE_OPENGL
+ 3 // RENDER_GLES_OPENGL
+};
+
+#endif // ANDROID
+
+#else // USE_OPENGL
+
+// map for index to RenderType
+const RenderType indexToRender[] =
+{
+ RENDER_SOFTWARE
+};
+
+const char *OPENGL_NAME[] =
+{
+ // TRANSLATORS: draw backend
+ N_("Software")
+};
+
+const int renderModesListSize = 1;
+
+const int renderToIndex[] =
+{
+ 0, // RENDER_SOFTWARE
+ 0, // RENDER_SOFTWARE
+ 0, // RENDER_SOFTWARE
+ 0 // RENDER_SOFTWARE
+};
+
+#endif // USE_OPENGL
+
+#endif // RENDER_RENDERERSLIST_H