summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-12-12 23:48:21 +0300
committerAndrei Karas <akaras@inbox.ru>2015-12-13 00:36:16 +0300
commitbe4ed51b29f77de23f6ffbf61df65554c6a394ad (patch)
treeb1afa1ff261cddc1f03d512cbfc3702f7cebd61c
parentff3c80151bd6ddbf0b963dd28c25dc1c47fd4347 (diff)
downloadmanaverse-be4ed51b29f77de23f6ffbf61df65554c6a394ad.tar.gz
manaverse-be4ed51b29f77de23f6ffbf61df65554c6a394ad.tar.bz2
manaverse-be4ed51b29f77de23f6ffbf61df65554c6a394ad.tar.xz
manaverse-be4ed51b29f77de23f6ffbf61df65554c6a394ad.zip
Not build unsupported render backends on nacl.
-rw-r--r--src/actions/actions.cpp2
-rw-r--r--src/graphicsmanager.cpp114
-rw-r--r--src/render/mobileopenglgraphics.cpp4
-rw-r--r--src/render/mobileopenglgraphics.h4
-rw-r--r--src/render/modernopenglgraphics.cpp4
-rw-r--r--src/render/modernopenglgraphics.h4
-rw-r--r--src/render/normalopenglgraphics.cpp4
-rw-r--r--src/render/normalopenglgraphics.h2
-rw-r--r--src/resources/openglimagehelper.cpp26
9 files changed, 104 insertions, 60 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 9e1d055ac..465200a5b 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -1366,7 +1366,7 @@ impHandler(dumpTests)
impHandler0(dumpOGL)
{
-#if defined USE_OPENGL && !defined ANDROID
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
NormalOpenGLGraphics::dumpSettings();
#endif
return true;
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index d3b5a8c55..90b1c5a69 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -166,7 +166,7 @@ int GraphicsManager::detectGraphics()
logger->log1("enable opengl mode");
int textureSampler = 0;
int compressTextures = 0;
-#ifndef ANDROID
+#if !defined(ANDROID) && !defined(__native_client__)
mainGraphics = new NormalOpenGLGraphics;
#endif
SDL_Window *const window = createWindow(100, 100, 0,
@@ -249,6 +249,67 @@ int GraphicsManager::detectGraphics()
| (1024 * textureSampler) | (2048 * compressTextures);
}
+#ifdef USE_SDL2
+#define RENDER_SOFTWARE_INIT \
+ imageHelper = new SDL2SoftwareImageHelper; \
+ surfaceImageHelper = new SurfaceImageHelper; \
+ mainGraphics = new SDL2SoftwareGraphics;
+#define RENDER_SDL2_DEFAULT_INIT \
+ imageHelper = new SDLImageHelper; \
+ surfaceImageHelper = new SurfaceImageHelper; \
+ mainGraphics = new SDLGraphics; \
+ mainGraphics->setRendererFlags(SDL_RENDERER_ACCELERATED); \
+ mUseTextureSampler = false;
+#else // USE_SDL2
+#define RENDER_SOFTWARE_INIT \
+ imageHelper = new SDLImageHelper; \
+ surfaceImageHelper = imageHelper; \
+ mainGraphics = new SDLGraphics;
+#define RENDER_SDL2_DEFAULT_INIT
+#endif // USE_SDL2
+
+#if defined(ANDROID) || defined(__native_client__)
+#define RENDER_NORMAL_OPENGL_INIT
+#define RENDER_MODERN_OPENGL_INIT
+#else // defined(ANDROID) || defined(__native_client__)
+#define RENDER_NORMAL_OPENGL_INIT \
+ imageHelper = new OpenGLImageHelper; \
+ surfaceImageHelper = new SurfaceImageHelper; \
+ mainGraphics = new NormalOpenGLGraphics; \
+ mUseTextureSampler = true;
+#define RENDER_MODERN_OPENGL_INIT \
+ imageHelper = new OpenGLImageHelper; \
+ surfaceImageHelper = new SurfaceImageHelper; \
+ mainGraphics = new ModernOpenGLGraphics; \
+ mUseTextureSampler = true;
+#endif // defined(ANDROID) || defined(__native_client__)
+
+#if defined(ANDROID)
+#define RENDER_SAFE_OPENGL_INIT
+#define RENDER_GLES2_OPENGL_INIT
+#else // defined(ANDROID)
+#define RENDER_SAFE_OPENGL_INIT \
+ imageHelper = new OpenGLImageHelper; \
+ surfaceImageHelper = new SurfaceImageHelper; \
+ mainGraphics = new SafeOpenGLGraphics; \
+ mUseTextureSampler = false;
+#define RENDER_GLES2_OPENGL_INIT \
+ imageHelper = new OpenGLImageHelper; \
+ surfaceImageHelper = new SurfaceImageHelper; \
+ mainGraphics = new MobileOpenGL2Graphics; \
+ mUseTextureSampler = false;
+#endif // defined(ANDROID)
+
+#if defined(__native_client__)
+#define RENDER_GLES_OPENGL_INIT
+#else // defined(__native_client__)
+#define RENDER_GLES_OPENGL_INIT \
+ imageHelper = new OpenGLImageHelper; \
+ surfaceImageHelper = new SurfaceImageHelper; \
+ mainGraphics = new MobileOpenGLGraphics; \
+ mUseTextureSampler = false;
+#endif // defined(__native_client__)
+
void GraphicsManager::createRenderers()
{
RenderType useOpenGL = RENDER_SOFTWARE;
@@ -272,64 +333,31 @@ void GraphicsManager::createRenderers()
switch (useOpenGL)
{
case RENDER_SOFTWARE:
-#ifdef USE_SDL2
- imageHelper = new SDL2SoftwareImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new SDL2SoftwareGraphics;
-#else
- imageHelper = new SDLImageHelper;
- surfaceImageHelper = imageHelper;
- mainGraphics = new SDLGraphics;
-#endif
+ RENDER_SOFTWARE_INIT
mUseTextureSampler = false;
break;
- case RENDER_NORMAL_OPENGL:
-#ifndef USE_SDL2
- case RENDER_SDL2_DEFAULT:
-#endif
case RENDER_LAST:
case RENDER_NULL:
default:
-#ifndef ANDROID
- imageHelper = new OpenGLImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new NormalOpenGLGraphics;
- mUseTextureSampler = true;
+ break;
+ case RENDER_NORMAL_OPENGL:
+ RENDER_NORMAL_OPENGL_INIT
break;
case RENDER_SAFE_OPENGL:
- imageHelper = new OpenGLImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new SafeOpenGLGraphics;
- mUseTextureSampler = false;
+ RENDER_SAFE_OPENGL_INIT
break;
case RENDER_MODERN_OPENGL:
- imageHelper = new OpenGLImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new ModernOpenGLGraphics;
- mUseTextureSampler = true;
+ RENDER_MODERN_OPENGL_INIT
break;
case RENDER_GLES2_OPENGL:
- imageHelper = new OpenGLImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new MobileOpenGL2Graphics;
- mUseTextureSampler = false;
+ RENDER_GLES2_OPENGL_INIT
break;
-#endif
case RENDER_GLES_OPENGL:
- imageHelper = new OpenGLImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new MobileOpenGLGraphics;
- mUseTextureSampler = false;
+ RENDER_GLES_OPENGL_INIT
break;
-#ifdef USE_SDL2
case RENDER_SDL2_DEFAULT:
- imageHelper = new SDLImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new SDLGraphics;
- mainGraphics->setRendererFlags(SDL_RENDERER_ACCELERATED);
- mUseTextureSampler = false;
+ RENDER_SDL2_DEFAULT_INIT
break;
-#endif
};
mUseAtlases = (useOpenGL == RENDER_NORMAL_OPENGL ||
useOpenGL == RENDER_SAFE_OPENGL ||
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 995a36c84..4eecfa232 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/>.
*/
-#ifdef USE_OPENGL
+#if defined(USE_OPENGL) && !defined(__native_client__)
#include "render/mobileopenglgraphics.h"
@@ -1379,4 +1379,4 @@ void MobileOpenGLGraphics::debugBindTexture(const Image *const image A_UNUSED)
}
#endif
-#endif // USE_OPENGL
+#endif // defined(USE_OPENGL) && !defined(__native_client__)
diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h
index 5011bae9e..ff722671e 100644
--- a/src/render/mobileopenglgraphics.h
+++ b/src/render/mobileopenglgraphics.h
@@ -23,7 +23,7 @@
#ifndef RENDER_MOBILEOPENGLGRAPHICS_H
#define RENDER_MOBILEOPENGLGRAPHICS_H
-#ifdef USE_OPENGL
+#if defined(USE_OPENGL) && !defined(__native_client__)
#include "localconsts.h"
#include "render/graphics.h"
@@ -96,6 +96,6 @@ class MobileOpenGLGraphics final : public Graphics
#endif
FBOInfo mFbo;
};
-#endif
+#endif // defined(USE_OPENGL) && !defined(__native_client__)
#endif // RENDER_MOBILEOPENGLGRAPHICS_H
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index 1e07810ed..f9fb6c25f 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
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
#include "render/modernopenglgraphics.h"
@@ -1372,4 +1372,4 @@ void ModernOpenGLGraphics::debugBindTexture(const Image *const image A_UNUSED)
}
#endif
-#endif // USE_OPENGL
+#endif // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h
index b1ee15a8f..5bdb70ea6 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
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
#include "localconsts.h"
#include "render/graphics.h"
@@ -135,6 +135,6 @@ class ModernOpenGLGraphics final : public Graphics
#endif
FBOInfo mFbo;
};
-#endif
+#endif // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
#endif // RENDER_MODERNOPENGLGRAPHICS_H
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index eb5609b19..2c28f4a79 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
+#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
#include "render/normalopenglgraphics.h"
@@ -1725,4 +1725,4 @@ void NormalOpenGLGraphics::debugBindTexture(const Image *const image A_UNUSED)
}
#endif
-#endif // USE_OPENGL
+#endif // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h
index 7d73223b6..fa8c8456a 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
+#if defined USE_OPENGL && !defined ANDROID && !defined(__native_client__)
#include "localconsts.h"
#include "render/graphics.h"
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index d76336ced..0d98fcfe7 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -249,27 +249,43 @@ void OpenGLImageHelper::bindTexture(const GLuint texture)
{
switch (mUseOpenGL)
{
-#ifndef ANDROID
+#ifdef ANDROID
case RENDER_NORMAL_OPENGL:
- NormalOpenGLGraphics::bindTexture(mTextureType, texture);
+ case RENDER_SAFE_OPENGL:
+ case RENDER_MODERN_OPENGL:
+ case RENDER_GLES2_OPENGL:
+ break;
+ case RENDER_GLES_OPENGL:
+ MobileOpenGLGraphics::bindTexture(mTextureType, texture);
break;
+#elif defined(__native_client__)
+ case RENDER_NORMAL_OPENGL:
case RENDER_MODERN_OPENGL:
- ModernOpenGLGraphics::bindTexture(mTextureType, texture);
+ case RENDER_GLES_OPENGL:
break;
case RENDER_SAFE_OPENGL:
SafeOpenGLGraphics::bindTexture(mTextureType, texture);
break;
+ case RENDER_GLES2_OPENGL:
+ MobileOpenGL2Graphics::bindTexture(mTextureType, texture);
+ break;
#else
case RENDER_NORMAL_OPENGL:
- case RENDER_SAFE_OPENGL:
+ NormalOpenGLGraphics::bindTexture(mTextureType, texture);
+ break;
case RENDER_MODERN_OPENGL:
-#endif
+ ModernOpenGLGraphics::bindTexture(mTextureType, texture);
+ break;
+ case RENDER_SAFE_OPENGL:
+ SafeOpenGLGraphics::bindTexture(mTextureType, texture);
+ break;
case RENDER_GLES_OPENGL:
MobileOpenGLGraphics::bindTexture(mTextureType, texture);
break;
case RENDER_GLES2_OPENGL:
MobileOpenGL2Graphics::bindTexture(mTextureType, texture);
break;
+#endif
case RENDER_SOFTWARE:
case RENDER_SDL2_DEFAULT:
case RENDER_NULL: