From 1ffeeb5d960ecf45ff285b8045265bb38de86b18 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 15 Dec 2015 18:57:03 +0300 Subject: Add safeopenglimagehelper for using in safe opengl mode only. --- src/render/graphics.cpp | 19 +++++++++++++++---- src/render/safeopenglgraphics.cpp | 24 ++++++++++++------------ 2 files changed, 27 insertions(+), 16 deletions(-) (limited to 'src/render') diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index a8dde9626..f038fdfff 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -77,11 +77,14 @@ #include "resources/imagehelper.h" #ifdef USE_OPENGL #include "resources/openglimagehelper.h" -#if defined(__native_client__) +#ifndef ANDROID +#include "resources/safeopenglimagehelper.h" +#endif // ANDROID +#ifdef __native_client__ #include "render/naclfunctions.h" #include "render/naclgles.h" -#endif -#endif +#endif // __native_client__ +#endif // USE_OPENGL #ifdef USE_OPENGL #ifdef __APPLE__ @@ -332,12 +335,20 @@ bool Graphics::setOpenGLMode() OpenGLImageHelper::mTextureSize = texSize; logger->log("OpenGL texture size: %d pixels (rectangle textures)", OpenGLImageHelper::mTextureSize); +#ifndef ANDROID + SafeOpenGLImageHelper::mTextureType = GL_TEXTURE_RECTANGLE_ARB; + SafeOpenGLImageHelper::mTextureSize = texSize; +#endif } else { - OpenGLImageHelper::mTextureType = GL_TEXTURE_2D; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize); + OpenGLImageHelper::mTextureType = GL_TEXTURE_2D; OpenGLImageHelper::mTextureSize = texSize; +#ifndef ANDROID + SafeOpenGLImageHelper::mTextureType = GL_TEXTURE_2D; + SafeOpenGLImageHelper::mTextureSize = texSize; +#endif logger->log("OpenGL texture size: %d pixels", OpenGLImageHelper::mTextureSize); } diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index f7638c5a1..f2609c299 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -30,7 +30,7 @@ #include "resources/image.h" #include "resources/imagerect.h" -#include "resources/openglimagehelper.h" +#include "resources/safeopenglimagehelper.h" #include "utils/sdlcheckutils.h" @@ -81,7 +81,7 @@ static inline void drawQuad(const Image *image, const int dstX, const int dstY, const int width, const int height) { - if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) + if (SafeOpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { const float tw = static_cast(image->mTexWidth); const float th = static_cast(image->mTexHeight); @@ -127,7 +127,7 @@ static inline void drawRescaledQuad(const Image *const image, const int desiredWidth, const int desiredHeight) { - if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) + if (SafeOpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { const float tw = static_cast(image->mTexWidth); const float th = static_cast(image->mTexHeight); @@ -173,7 +173,7 @@ void SafeOpenGLGraphics::drawImageInline(const Image *const image, return; setColorAlpha(image->mAlpha); - bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); + bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage); setTexturingAndBlending(true); const SDL_Rect &bounds = image->mBounds; @@ -192,7 +192,7 @@ void SafeOpenGLGraphics::copyImage(const Image *const image, void SafeOpenGLGraphics::testDraw() { - if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) + if (SafeOpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.781250f); @@ -228,7 +228,7 @@ void SafeOpenGLGraphics::drawImageCached(const Image *const image, return; setColorAlpha(image->mAlpha); - bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); + bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage); setTexturingAndBlending(true); const SDL_Rect &bounds = image->mBounds; @@ -256,7 +256,7 @@ void SafeOpenGLGraphics::drawPatternCached(const Image *const image, const int srcY = imageRect.y; setColorAlpha(image->mAlpha); - bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); + bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage); setTexturingAndBlending(true); // Draw a set of textured rectangles @@ -300,7 +300,7 @@ void SafeOpenGLGraphics::drawRescaledImage(const Image *const image, } setColorAlpha(image->mAlpha); - bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); + bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage); setTexturingAndBlending(true); // Draw a textured quad. @@ -335,7 +335,7 @@ void SafeOpenGLGraphics::drawPatternInline(const Image *const image, const int srcY = imageRect.y; setColorAlpha(image->mAlpha); - bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); + bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage); setTexturingAndBlending(true); // Draw a set of textured rectangles @@ -375,7 +375,7 @@ void SafeOpenGLGraphics::drawRescaledPattern(const Image *const image, const int srcY = imageRect.y; setColorAlpha(image->mAlpha); - bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage); + bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage); setTexturingAndBlending(true); // Draw a set of textured rectangles @@ -676,7 +676,7 @@ void SafeOpenGLGraphics::setTexturingAndBlending(const bool enable) { if (!mTexture) { - glEnable(OpenGLImageHelper::mTextureType); + glEnable(SafeOpenGLImageHelper::mTextureType); mTexture = true; } @@ -702,7 +702,7 @@ void SafeOpenGLGraphics::setTexturingAndBlending(const bool enable) if (mTexture) { - glDisable(OpenGLImageHelper::mTextureType); + glDisable(SafeOpenGLImageHelper::mTextureType); mTexture = false; } } -- cgit v1.2.3-70-g09d2