summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-08 01:04:33 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-08 01:04:33 +0300
commit410dd6c3d845cc0e19fd678090d95669bdeb5885 (patch)
treed9f0003f0f68212d1c99890f603c3d280b24669b /src
parentdce5065a2df5f6ac0057702f704b6ab4f16ce8f8 (diff)
downloadmv-410dd6c3d845cc0e19fd678090d95669bdeb5885.tar.gz
mv-410dd6c3d845cc0e19fd678090d95669bdeb5885.tar.bz2
mv-410dd6c3d845cc0e19fd678090d95669bdeb5885.tar.xz
mv-410dd6c3d845cc0e19fd678090d95669bdeb5885.zip
Add Modern OpenGL render type.
Now it using normal OpenGL renderer.
Diffstat (limited to 'src')
-rw-r--r--src/graphicsmanager.cpp25
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.cpp4
-rw-r--r--src/render/graphics.cpp1
-rw-r--r--src/render/renderers.cpp14
-rw-r--r--src/render/rendererslistsdl.h18
-rw-r--r--src/render/rendererslistsdl2.h18
-rw-r--r--src/render/rendertype.h3
-rw-r--r--src/resources/image.cpp6
-rw-r--r--src/resources/map/map.cpp7
-rw-r--r--src/resources/openglimagehelper.cpp2
-rw-r--r--src/test/testmain.cpp5
11 files changed, 73 insertions, 30 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 90f723f82..33cbd0224 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -272,6 +272,7 @@ void GraphicsManager::createRenderers()
mUseTextureSampler = false;
break;
case RENDER_NORMAL_OPENGL:
+ case RENDER_MODERN_OPENGL:
#ifndef USE_SDL2
case RENDER_SDL2_DEFAULT:
#endif
@@ -328,6 +329,7 @@ void GraphicsManager::createRenderers()
case RENDER_SOFTWARE:
case RENDER_SAFE_OPENGL:
case RENDER_GLES_OPENGL:
+ case RENDER_MODERN_OPENGL:
case RENDER_NORMAL_OPENGL:
case RENDER_NULL:
case RENDER_LAST:
@@ -450,18 +452,30 @@ void GraphicsManager::initGraphics()
detectPixelSize();
setVideoMode();
#ifdef USE_OPENGL
+ const RenderType oldOpenGLMode = openGLMode;
+ if (openGLMode == RENDER_MODERN_OPENGL)
+ {
+ if (!checkGLVersion(3, 0))
+ {
+ logger->log("Fallback to normal OpenGL mode");
+ openGLMode = RENDER_NORMAL_OPENGL;
+ }
+ }
if (openGLMode == RENDER_NORMAL_OPENGL || openGLMode == RENDER_GLES_OPENGL)
{
if (!checkGLVersion(2, 0))
{
logger->log("Fallback to safe OpenGL mode");
openGLMode = RENDER_SAFE_OPENGL;
- deleteRenderers();
- createRenderers();
- detectPixelSize();
- setVideoMode();
}
}
+ if (openGLMode != oldOpenGLMode)
+ {
+ deleteRenderers();
+ createRenderers();
+ detectPixelSize();
+ setVideoMode();
+ }
#endif
}
@@ -688,9 +702,6 @@ void GraphicsManager::updateTextureFormat() const
logger->log1("using 4 texture format");
}
}
-#endif
-
-#ifdef USE_OPENGL
void GraphicsManager::logString(const char *const format, const int num)
{
diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp
index 9f987c721..d538ba91a 100644
--- a/src/gui/widgets/tabs/debugwindowtabs.cpp
+++ b/src/gui/widgets/tabs/debugwindowtabs.cpp
@@ -109,6 +109,10 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
// TRANSLATORS: debug window label
mFPSText = _("%d FPS (mobile OpenGL)");
break;
+ case RENDER_MODERN_OPENGL:
+ // TRANSLATORS: debug window label
+ mFPSText = _("%d FPS (modern OpenGL)");
+ break;
case RENDER_SDL2_DEFAULT:
// TRANSLATORS: debug window label
mFPSText = _("%d FPS (SDL2 default)");
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index 44307add7..5bb90e753 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -303,6 +303,7 @@ bool Graphics::setOpenGLMode()
if (rectTex
&& OpenGLImageHelper::getInternalTextureType() == 4
&& getOpenGL() != RENDER_GLES_OPENGL
+ && getOpenGL() != RENDER_MODERN_OPENGL
&& config.getBoolValue("rectangulartextures")
&& !graphicsManager.isUseTextureSampler())
{
diff --git a/src/render/renderers.cpp b/src/render/renderers.cpp
index a26cb8b96..76aef6468 100644
--- a/src/render/renderers.cpp
+++ b/src/render/renderers.cpp
@@ -42,18 +42,24 @@ RenderType intToRenderType(const int mode)
if (mode != RENDER_SOFTWARE
#if defined(USE_OPENGL) && defined(ANDROID) && defined(USE_SDL2)
- && mode != RENDER_GLES_OPENGL && mode != RENDER_SDL2_DEFAULT)
+ && mode != RENDER_GLES_OPENGL
+ && mode != RENDER_SDL2_DEFAULT)
#elif defined(USE_OPENGL) && defined(ANDROID) && !defined(USE_SDL2)
&& mode != RENDER_GLES_OPENGL)
#elif defined(USE_OPENGL) && !defined(ANDROID) && defined(USE_SDL2)
- && mode != RENDER_NORMAL_OPENGL && mode != RENDER_SAFE_OPENGL
- && mode != RENDER_GLES_OPENGL && mode != RENDER_SDL2_DEFAULT)
+ && mode != RENDER_NORMAL_OPENGL
+ && mode != RENDER_MODERN_OPENGL
+ && mode != RENDER_SAFE_OPENGL
+ && mode != RENDER_GLES_OPENGL
+ && mode != RENDER_SDL2_DEFAULT)
#elif !defined(USE_OPENGL) && defined(USE_SDL2)
&& mode != RENDER_SDL2_DEFAULT)
#elif !defined(USE_OPENGL) && !defined(USE_SDL2)
)
#elif defined(USE_OPENGL) && !defined(ANDROID) && !defined(USE_SDL2)
- && mode != RENDER_NORMAL_OPENGL && mode != RENDER_SAFE_OPENGL
+ && mode != RENDER_NORMAL_OPENGL
+ && mode != RENDER_MODERN_OPENGL
+ && mode != RENDER_SAFE_OPENGL
&& mode != RENDER_GLES_OPENGL)
#endif
{
diff --git a/src/render/rendererslistsdl.h b/src/render/rendererslistsdl.h
index b2c3b2354..18960beda 100644
--- a/src/render/rendererslistsdl.h
+++ b/src/render/rendererslistsdl.h
@@ -57,7 +57,8 @@ const int renderToIndex[] =
1, // RENDER_NORMAL_OPENGL
1, // RENDER_SAFE_OPENGL
1, // RENDER_GLES_OPENGL
- 1 // RENDER_SDL2_DEFAULT
+ 1, // RENDER_SDL2_DEFAULT
+ 1 // RENDER_MODERN_OPENGL
};
#else // ANDROID
@@ -69,7 +70,8 @@ const RenderType indexToRender[] =
RENDER_SOFTWARE,
RENDER_NORMAL_OPENGL,
RENDER_SAFE_OPENGL,
- RENDER_GLES_OPENGL
+ RENDER_GLES_OPENGL,
+ RENDER_MODERN_OPENGL
};
const char *OPENGL_NAME[] =
@@ -81,10 +83,12 @@ const char *OPENGL_NAME[] =
// TRANSLATORS: draw backend
N_("Safe OpenGL"),
// TRANSLATORS: draw backend
- N_("Mobile OpenGL")
+ N_("Mobile OpenGL"),
+ // TRANSLATORS: draw backend
+ N_("Modern OpenGL")
};
-const int renderModesListSize = 4;
+const int renderModesListSize = 5;
const int renderToIndex[] =
{
@@ -92,7 +96,8 @@ const int renderToIndex[] =
1, // RENDER_NORMAL_OPENGL
2, // RENDER_SAFE_OPENGL
3, // RENDER_GLES_OPENGL
- 0 // RENDER_SDL2_DEFAULT
+ 0, // RENDER_SDL2_DEFAULT
+ 4 // RENDER_MODERN_OPENGL
};
#endif // ANDROID
@@ -120,7 +125,8 @@ const int renderToIndex[] =
0, // RENDER_NORMAL_OPENGL
0, // RENDER_SAFE_OPENGL
0, // RENDER_GLES_OPENGL
- 0 // RENDER_SDL2_DEFAULT
+ 0, // RENDER_SDL2_DEFAULT
+ 0 // RENDER_MODERN_OPENGL
};
#endif // USE_OPENGL
diff --git a/src/render/rendererslistsdl2.h b/src/render/rendererslistsdl2.h
index 1ebe4b242..2bb309f91 100644
--- a/src/render/rendererslistsdl2.h
+++ b/src/render/rendererslistsdl2.h
@@ -57,7 +57,8 @@ const int renderToIndex[] =
2, // RENDER_NORMAL_OPENGL
2, // RENDER_SAFE_OPENGL
2, // RENDER_GLES_OPENGL
- 1 // RENDER_SDL2_DEFAULT
+ 1, // RENDER_SDL2_DEFAULT
+ 2 // RENDER_MODERN_OPENGL
};
#else // ANDROID
@@ -70,7 +71,8 @@ const RenderType indexToRender[] =
RENDER_SDL2_DEFAULT,
RENDER_NORMAL_OPENGL,
RENDER_SAFE_OPENGL,
- RENDER_GLES_OPENGL
+ RENDER_GLES_OPENGL,
+ RENDER_MODERN_OPENGL
};
const char *OPENGL_NAME[] =
@@ -84,10 +86,12 @@ const char *OPENGL_NAME[] =
// TRANSLATORS: draw backend
N_("Safe OpenGL"),
// TRANSLATORS: draw backend
- N_("Mobile OpenGL")
+ N_("Mobile OpenGL"),
+ // TRANSLATORS: draw backend
+ N_("Modern OpenGL")
};
-const int renderModesListSize = 5;
+const int renderModesListSize = 6;
const int renderToIndex[] =
{
@@ -95,7 +99,8 @@ const int renderToIndex[] =
2, // RENDER_NORMAL_OPENGL
3, // RENDER_SAFE_OPENGL
4, // RENDER_GLES_OPENGL
- 1 // RENDER_SDL2_DEFAULT
+ 1, // RENDER_SDL2_DEFAULT
+ 5 // RENDER_MODERN_OPENGL
};
#endif // ANDROID
@@ -126,7 +131,8 @@ const int renderToIndex[] =
0, // RENDER_NORMAL_OPENGL
0, // RENDER_SAFE_OPENGL
0, // RENDER_GLES_OPENGL
- 1 // RENDER_SDL2_DEFAULT
+ 1, // RENDER_SDL2_DEFAULT
+ 0 // RENDER_MODERN_OPENGL
};
#endif // USE_OPENGL
diff --git a/src/render/rendertype.h b/src/render/rendertype.h
index cb4150188..cf8160c52 100644
--- a/src/render/rendertype.h
+++ b/src/render/rendertype.h
@@ -28,7 +28,8 @@ enum RenderType
RENDER_SAFE_OPENGL = 2,
RENDER_GLES_OPENGL = 3,
RENDER_SDL2_DEFAULT = 4,
- RENDER_NULL = 5,
+ RENDER_MODERN_OPENGL = 5,
+ RENDER_NULL = 6,
RENDER_LAST
};
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index d2a1eb2dd..d9d2a8a01 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -439,8 +439,10 @@ Image *Image::getSubImage(const int x, const int y,
// Create a new clipped sub-image
#ifdef USE_OPENGL
const RenderType mode = OpenGLImageHelper::mUseOpenGL;
- if (mode == RENDER_NORMAL_OPENGL || mode == RENDER_SAFE_OPENGL
- || mode == RENDER_GLES_OPENGL)
+ if (mode == RENDER_NORMAL_OPENGL
+ || mode == RENDER_SAFE_OPENGL
+ || mode == RENDER_GLES_OPENGL
+ || mode == RENDER_MODERN_OPENGL)
{
return new SubImage(this, mGLImage, x, y, width, height,
mTexWidth, mTexHeight);
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index 7ba798319..279262124 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -352,7 +352,9 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY)
#ifdef USE_OPENGL
int updateFlag = 0;
- if (mOpenGL == RENDER_NORMAL_OPENGL || mOpenGL == RENDER_GLES_OPENGL)
+ if (mOpenGL == RENDER_NORMAL_OPENGL
+ || mOpenGL == RENDER_GLES_OPENGL
+ || mOpenGL == RENDER_MODERN_OPENGL)
{
if (mLastX != startX || mLastY != startY || mLastScrollX != scrollX
|| mLastScrollY != scrollY)
@@ -411,7 +413,8 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY)
{
#ifdef USE_OPENGL
if (mOpenGL == RENDER_NORMAL_OPENGL
- || mOpenGL == RENDER_GLES_OPENGL)
+ || mOpenGL == RENDER_GLES_OPENGL
+ || mOpenGL == RENDER_MODERN_OPENGL)
{
if (updateFlag)
{
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index 6d25aa952..ca5f6410a 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -202,6 +202,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
{
#ifndef ANDROID
case RENDER_NORMAL_OPENGL:
+ case RENDER_MODERN_OPENGL:
NormalOpenGLGraphics::bindTexture(mTextureType, texture);
break;
case RENDER_SAFE_OPENGL:
@@ -210,6 +211,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
#else
case RENDER_NORMAL_OPENGL:
case RENDER_SAFE_OPENGL:
+ case RENDER_MODERN_OPENGL:
#endif
case RENDER_GLES_OPENGL:
MobileOpenGLGraphics::bindTexture(mTextureType, texture);
diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp
index 9ef4fdc23..93174f94d 100644
--- a/src/test/testmain.cpp
+++ b/src/test/testmain.cpp
@@ -192,9 +192,10 @@ int TestMain::exec(const bool testAudio)
int batchSize = 256;
- // if OpenGL mode is fast mode we can try detect max batch sizes
+ // if OpenGL mode is normal mode we can try detect max batch sizes
if (openGLMode == RENDER_NORMAL_OPENGL
- || openGLMode == RENDER_GLES_OPENGL)
+ || openGLMode == RENDER_GLES_OPENGL
+ || openGLMode == RENDER_MODERN_OPENGL)
{
if (!invokeNormalOpenBatchTest("11"))
batchSize = readValue2(11);