summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcpasjuste <cpasjuste@gmail.com>2020-04-23 11:16:31 +0200
committercpasjuste <cpasjuste@gmail.com>2020-04-23 11:16:31 +0200
commite124615493f4f84d372a99ea604220a8e850dde1 (patch)
treeaf5a867b9acc4b528b962066cbf663cca95770b2 /src
parent177077c6563245504e4aa443cce3bdba7c65db42 (diff)
downloadManaVerse-e124615493f4f84d372a99ea604220a8e850dde1.tar.gz
ManaVerse-e124615493f4f84d372a99ea604220a8e850dde1.tar.bz2
ManaVerse-e124615493f4f84d372a99ea604220a8e850dde1.tar.xz
ManaVerse-e124615493f4f84d372a99ea604220a8e850dde1.zip
switch: enable opengles2 renderer
Diffstat (limited to 'src')
-rw-r--r--src/graphicsmanager.cpp18
-rw-r--r--src/progs/manaplus/actions/actions.cpp2
-rw-r--r--src/render/graphics.cpp4
-rw-r--r--src/render/mobileopenglgraphics.cpp2
-rw-r--r--src/render/mobileopenglgraphics.h2
-rw-r--r--src/render/modernopenglgraphics.cpp2
-rw-r--r--src/render/modernopenglgraphics.h2
-rw-r--r--src/render/normalopenglgraphics.cpp2
-rw-r--r--src/render/normalopenglgraphics.h2
-rw-r--r--src/render/opengl/mglfunctions.h2
-rw-r--r--src/render/renderers.cpp2
-rw-r--r--src/render/rendererslistsdl2.h6
-rw-r--r--src/render/safeopenglgraphics.cpp2
-rw-r--r--src/render/safeopenglgraphics.h2
-rw-r--r--src/resources/openglimagehelper.cpp6
-rw-r--r--src/resources/safeopenglimagehelper.cpp2
-rw-r--r--src/resources/safeopenglimagehelper.h2
17 files changed, 35 insertions, 25 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 2bdfdac43..f45439937 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -186,7 +186,7 @@ int GraphicsManager::detectGraphics()
logger->log1("enable opengl mode");
int textureSampler = 0;
int compressTextures = 0;
-#if !defined(ANDROID) && !defined(__native_client__)
+#if !defined(ANDROID) && !defined(__native_client__) && !defined(__SWITCH__)
mainGraphics = new NormalOpenGLGraphics;
#endif // !defined(ANDROID) && !defined(__native_client__)
@@ -285,7 +285,7 @@ int GraphicsManager::detectGraphics()
#define RENDER_SDL2_DEFAULT_INIT
#endif // USE_SDL2
-#if defined(ANDROID) || defined(__native_client__)
+#if defined(ANDROID) || defined(__native_client__) || defined(__SWITCH__)
#define RENDER_NORMAL_OPENGL_INIT
#define RENDER_MODERN_OPENGL_INIT
#else // defined(ANDROID) || defined(__native_client__)
@@ -307,12 +307,16 @@ int GraphicsManager::detectGraphics()
#define RENDER_SAFE_OPENGL_INIT
#define RENDER_GLES2_OPENGL_INIT
#else // defined(ANDROID)
+#ifdef __SWITCH__
+#define RENDER_SAFE_OPENGL_INIT
+#else
#define RENDER_SAFE_OPENGL_INIT \
imageHelper = new SafeOpenGLImageHelper; \
surfaceImageHelper = new SurfaceImageHelper; \
mainGraphics = new SafeOpenGLGraphics; \
screenshortHelper = new OpenGLScreenshotHelper; \
mUseTextureSampler = false;
+#endif
#define RENDER_GLES2_OPENGL_INIT \
imageHelper = new OpenGLImageHelper; \
surfaceImageHelper = new SurfaceImageHelper; \
@@ -321,7 +325,7 @@ int GraphicsManager::detectGraphics()
mUseTextureSampler = false;
#endif // defined(ANDROID)
-#if defined(__native_client__)
+#if defined(__native_client__) || defined(__SWITCH__)
#define RENDER_GLES_OPENGL_INIT
#else // defined(__native_client__)
#define RENDER_GLES_OPENGL_INIT \
@@ -533,7 +537,7 @@ void GraphicsManager::initGraphics()
openGLMode = intToRenderType(config.getIntValue("opengl"));
#ifdef USE_OPENGL
OpenGLImageHelper::setBlur(config.getBoolValue("blur"));
-#ifndef ANDROID
+#if !defined(ANDROID) && !defined(__SWITCH__)
SafeOpenGLImageHelper::setBlur(config.getBoolValue("blur"));
#endif // ANDROID
SurfaceImageHelper::SDLSetEnableAlphaCache(
@@ -844,7 +848,7 @@ void GraphicsManager::updateTextureFormat()
config.getBoolValue("newtextures"))
{
OpenGLImageHelper::setInternalTextureType(GL_RGBA);
-#ifndef ANDROID
+#if !defined(ANDROID) && !defined(__SWITCH__)
SafeOpenGLImageHelper::setInternalTextureType(GL_RGBA);
#endif // ANDROID
@@ -853,7 +857,7 @@ void GraphicsManager::updateTextureFormat()
else
{
OpenGLImageHelper::setInternalTextureType(4);
-#ifndef ANDROID
+#if !defined(ANDROID) && !defined(__SWITCH__)
SafeOpenGLImageHelper::setInternalTextureType(4);
#endif // ANDROID
@@ -1462,7 +1466,7 @@ void GraphicsManager::createTextureSampler()
}
}
OpenGLImageHelper::setUseTextureSampler(mUseTextureSampler);
-#ifndef ANDROID
+#if !defined(ANDROID) && !defined(__SWITCH__)
SafeOpenGLImageHelper::setUseTextureSampler(false);
#endif // ANDROID
}
diff --git a/src/progs/manaplus/actions/actions.cpp b/src/progs/manaplus/actions/actions.cpp
index 3a48e5a33..a4c6a63d2 100644
--- a/src/progs/manaplus/actions/actions.cpp
+++ b/src/progs/manaplus/actions/actions.cpp
@@ -1528,7 +1528,7 @@ impHandler(dumpTests)
impHandler0(dumpOGL)
{
-#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__) && !defined(__SWITCH__)
NormalOpenGLGraphics::dumpSettings();
#endif // defined(USE_OPENGL) && !defined(ANDROID) &&
// !defined(__native_client__)
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index cd88c25dd..ecc31f8f9 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -360,7 +360,7 @@ bool Graphics::setOpenGLMode() restrict2
OpenGLImageHelper::mTextureSize = texSize;
logger->log("OpenGL texture size: %d pixels (rectangle textures)",
OpenGLImageHelper::mTextureSize);
-#ifndef ANDROID
+#if !defined(ANDROID) && !defined(__SWITCH__)
SafeOpenGLImageHelper::mTextureType = GL_TEXTURE_RECTANGLE_ARB;
SafeOpenGLImageHelper::mTextureSize = texSize;
#endif // ANDROID
@@ -370,7 +370,7 @@ bool Graphics::setOpenGLMode() restrict2
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
OpenGLImageHelper::mTextureType = GL_TEXTURE_2D;
OpenGLImageHelper::mTextureSize = texSize;
-#ifndef ANDROID
+#if !defined(ANDROID) && !defined(__SWITCH__)
SafeOpenGLImageHelper::mTextureType = GL_TEXTURE_2D;
SafeOpenGLImageHelper::mTextureSize = texSize;
#endif // ANDROID
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 250cd8969..935833e0b 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#if defined(USE_OPENGL) && !defined(__native_client__)
+#if defined(USE_OPENGL) && !defined(__native_client__) && !defined(__SWITCH__)
#include "render/mobileopenglgraphics.h"
diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h
index 5cf018692..0496de283 100644
--- a/src/render/mobileopenglgraphics.h
+++ b/src/render/mobileopenglgraphics.h
@@ -23,7 +23,7 @@
#ifndef RENDER_MOBILEOPENGLGRAPHICS_H
#define RENDER_MOBILEOPENGLGRAPHICS_H
-#if defined(USE_OPENGL) && !defined(__native_client__)
+#if defined(USE_OPENGL) && !defined(__native_client__) && !defined(__SWITCH__)
#include "localconsts.h"
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index 937255c0e..15bb1505c 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__) && !defined(__SWITCH__)
#include "render/modernopenglgraphics.h"
diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h
index 087dbd95d..5c3e643ab 100644
--- a/src/render/modernopenglgraphics.h
+++ b/src/render/modernopenglgraphics.h
@@ -23,7 +23,7 @@
#ifndef RENDER_MODERNOPENGLGRAPHICS_H
#define RENDER_MODERNOPENGLGRAPHICS_H
-#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__) && !defined(__SWITCH__)
#include "localconsts.h"
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index 87b6a8a2a..666ef9ef4 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__) && !defined(__SWITCH__)
#include "render/normalopenglgraphics.h"
diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h
index c7866dc50..535d97f8e 100644
--- a/src/render/normalopenglgraphics.h
+++ b/src/render/normalopenglgraphics.h
@@ -23,7 +23,7 @@
#ifndef RENDER_NORMALOPENGLGRAPHICS_H
#define RENDER_NORMALOPENGLGRAPHICS_H
-#if defined USE_OPENGL && !defined ANDROID && !defined(__native_client__)
+#if defined USE_OPENGL && !defined ANDROID && !defined(__native_client__) && !defined(__SWITCH__)
#include "localconsts.h"
diff --git a/src/render/opengl/mglfunctions.h b/src/render/opengl/mglfunctions.h
index 11b387fdb..1126b48bb 100644
--- a/src/render/opengl/mglfunctions.h
+++ b/src/render/opengl/mglfunctions.h
@@ -35,6 +35,8 @@ LOGGER_H
#define getFunction(name) nullptr
#elif defined __native_client__
#define getFunction(name) glGetProcAddressREGAL(name)
+#elif defined(__SWITCH__)
+#define getFunction(name) SDL_GL_GetProcAddress(name)
#else // WIN32
#define getFunction(name) glXGetProcAddress(\
reinterpret_cast<const GLubyte*>(name))
diff --git a/src/render/renderers.cpp b/src/render/renderers.cpp
index efcad9ff2..40bb550bc 100644
--- a/src/render/renderers.cpp
+++ b/src/render/renderers.cpp
@@ -42,7 +42,7 @@ static RenderType getDefault() noexcept2
RenderType intToRenderType(const int mode) noexcept2
{
#ifdef __SWITCH__
- return RENDER_SDL2_DEFAULT;
+ return RENDER_GLES2_OPENGL;
#endif
if (mode < 0 || mode >= RENDER_LAST)
return getDefault();
diff --git a/src/render/rendererslistsdl2.h b/src/render/rendererslistsdl2.h
index b13324b2d..259643295 100644
--- a/src/render/rendererslistsdl2.h
+++ b/src/render/rendererslistsdl2.h
@@ -106,7 +106,7 @@ const RenderType indexToRender[] =
{
RENDER_SOFTWARE,
RENDER_SDL2_DEFAULT,
- RENDER_MODERN_OPENGL
+ RENDER_GLES2_OPENGL
};
const char *OPENGL_NAME[] =
@@ -116,14 +116,14 @@ const char *OPENGL_NAME[] =
// TRANSLATORS: draw backend
N_("SDL2 default"),
// TRANSLATORS: draw backend
- N_("Modern OpenGL")
+ N_("OpenGL ES 2")
};
const int renderModesListSize = 3;
const int renderToIndex[] =
{
- 2, // RENDER_SOFTWARE
+ 0, // RENDER_SOFTWARE
2, // RENDER_NORMAL_OPENGL
2, // RENDER_SAFE_OPENGL
2, // RENDER_GLES_OPENGL
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index 329ad34cb..8583ed6b5 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#if defined USE_OPENGL && !defined ANDROID
+#if defined USE_OPENGL && !defined ANDROID && !defined(__SWITCH__)
#include "render/safeopenglgraphics.h"
#ifdef DEBUG_OPENGL
diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h
index a064da020..55a1c8515 100644
--- a/src/render/safeopenglgraphics.h
+++ b/src/render/safeopenglgraphics.h
@@ -23,7 +23,7 @@
#ifndef RENDER_SAFEOPENGLGRAPHICS_H
#define RENDER_SAFEOPENGLGRAPHICS_H
-#if defined USE_OPENGL && !defined ANDROID
+#if defined USE_OPENGL && !defined ANDROID && !defined(__SWITCH__)
#include "render/graphics.h"
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index ce7bb0ac3..557d9d0a5 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -263,13 +263,15 @@ void OpenGLImageHelper::bindTexture(const GLuint texture)
case RENDER_GLES_OPENGL:
MobileOpenGLGraphics::bindTexture(mTextureType, texture);
break;
-#elif defined(__native_client__)
+#elif defined(__native_client__) || defined(__SWITCH__)
case RENDER_NORMAL_OPENGL:
case RENDER_MODERN_OPENGL:
case RENDER_GLES_OPENGL:
break;
case RENDER_SAFE_OPENGL:
+#ifndef __SWITCH__
SafeOpenGLGraphics::bindTexture(mTextureType, texture);
+#endif
break;
case RENDER_GLES2_OPENGL:
MobileOpenGL2Graphics::bindTexture(mTextureType, texture);
@@ -336,7 +338,9 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
mUseOpenGL != RENDER_GLES_OPENGL &&
mUseOpenGL != RENDER_GLES2_OPENGL)
{
+#ifndef __SWITCH__
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+#endif
#ifdef OPENGLERRORS
graphicsManager.logError();
#endif // OPENGLERRORS
diff --git a/src/resources/safeopenglimagehelper.cpp b/src/resources/safeopenglimagehelper.cpp
index 463b89507..4d94578c6 100644
--- a/src/resources/safeopenglimagehelper.cpp
+++ b/src/resources/safeopenglimagehelper.cpp
@@ -22,7 +22,7 @@
#include "resources/safeopenglimagehelper.h"
-#if defined(USE_OPENGL) && !defined(ANDROID)
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__SWITCH__)
#include "graphicsmanager.h"
diff --git a/src/resources/safeopenglimagehelper.h b/src/resources/safeopenglimagehelper.h
index 4a2e9346b..7b2098b11 100644
--- a/src/resources/safeopenglimagehelper.h
+++ b/src/resources/safeopenglimagehelper.h
@@ -25,7 +25,7 @@
#include "localconsts.h"
-#if defined(USE_OPENGL) && !defined(ANDROID)
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__SWITCH__)
#ifndef GL_TEXTURE_RECTANGLE_ARB
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5