summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render/mobileopengl2graphics.cpp77
-rw-r--r--src/render/mobileopenglgraphics.cpp82
-rw-r--r--src/render/modernopenglgraphics.cpp76
-rw-r--r--src/render/normalopenglgraphics.cpp82
-rw-r--r--src/render/nullopenglgraphics.cpp56
-rw-r--r--src/render/openglgraphicsdef.hpp4
-rw-r--r--src/render/safeopenglgraphics.cpp76
7 files changed, 221 insertions, 232 deletions
diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp
index 7ec1d601f..a0cc9167b 100644
--- a/src/render/mobileopengl2graphics.cpp
+++ b/src/render/mobileopengl2graphics.cpp
@@ -345,7 +345,7 @@ void MobileOpenGL2Graphics::drawImageInline(const Image *restrict const image,
debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
setColorAlpha(image->mAlpha);
@@ -433,7 +433,7 @@ void MobileOpenGL2Graphics::drawRescaledImage(const Image *
debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
@@ -484,7 +484,7 @@ void MobileOpenGL2Graphics::drawPatternInline(const Image *
#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
setColorAlpha(image->mAlpha);
@@ -548,7 +548,7 @@ void MobileOpenGL2Graphics::drawRescaledPattern(const Image *
#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
setColorAlpha(image->mAlpha);
@@ -719,7 +719,7 @@ void MobileOpenGL2Graphics::drawTileCollection(const ImageCollection
*restrict const vertCol)
restrict2
{
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
const ImageVertexesVector &draws = vertCol->draws;
const ImageCollectionCIter it_end = draws.end();
for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
@@ -833,7 +833,7 @@ void MobileOpenGL2Graphics::drawTileVertexes(const ImageVertexes *
debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture2(GL_TEXTURE_2D, image);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
drawVertexes(vert->ogl);
@@ -926,7 +926,7 @@ void MobileOpenGL2Graphics::popClipArea() restrict2
void MobileOpenGL2Graphics::drawPoint(int x, int y) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
GLfloat vertices[] =
@@ -947,7 +947,7 @@ void MobileOpenGL2Graphics::drawPoint(int x, int y) restrict2
void MobileOpenGL2Graphics::drawLine(int x1, int y1,
int x2, int y2) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
GLfloat vertices[] =
@@ -968,7 +968,7 @@ void MobileOpenGL2Graphics::drawLine(int x1, int y1,
void MobileOpenGL2Graphics::drawRectangle(const Rect &restrict rect) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
const GLfloat x1 = static_cast<GLfloat>(rect.x + clipArea.xOffset);
@@ -996,7 +996,7 @@ void MobileOpenGL2Graphics::drawRectangle(const Rect &restrict rect) restrict2
void MobileOpenGL2Graphics::fillRectangle(const Rect &restrict rect) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
const GLfloat x1 = static_cast<GLfloat>(rect.x + clipArea.xOffset);
@@ -1022,39 +1022,36 @@ void MobileOpenGL2Graphics::fillRectangle(const Rect &restrict rect) restrict2
#endif // OPENGLERRORS
}
-void MobileOpenGL2Graphics::setTexturingAndBlending(const bool enable)
- restrict2
+void MobileOpenGL2Graphics::enableTexturingAndBlending() restrict2
{
- if (enable)
+ if (!mTextureDraw)
{
- if (!mTextureDraw)
- {
- mTextureDraw = true;
- mglUniform1f(mDrawTypeUniform, 1.0f);
- }
- if (!mAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
+ mTextureDraw = true;
+ mglUniform1f(mDrawTypeUniform, 1.0f);
}
- else
+ if (!mAlpha)
{
- if (mTextureDraw)
- {
- mTextureDraw = false;
- mglUniform1f(mDrawTypeUniform, 0.0f);
- }
- if (mAlpha && !mColorAlpha)
- {
- mglDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
+ mglEnable(GL_BLEND);
+ mAlpha = true;
+ }
+}
+
+void MobileOpenGL2Graphics::disableTexturingAndBlending() restrict2
+{
+ if (mTextureDraw)
+ {
+ mTextureDraw = false;
+ mglUniform1f(mDrawTypeUniform, 0.0f);
+ }
+ if (mAlpha && !mColorAlpha)
+ {
+ mglDisable(GL_BLEND);
+ mAlpha = false;
+ }
+ else if (!mAlpha && mColorAlpha)
+ {
+ mglEnable(GL_BLEND);
+ mAlpha = true;
}
}
@@ -1073,7 +1070,7 @@ void MobileOpenGL2Graphics::drawNet(const int x1,
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
const GLfloat dx = static_cast<GLfloat>(clipArea.xOffset);
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index b2baa7d66..853757a22 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -291,7 +291,7 @@ void MobileOpenGLGraphics::drawImageInline(const Image *restrict const image,
debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
const SDL_Rect &imageRect = image->mBounds;
drawQuad(image, imageRect.x, imageRect.y,
@@ -427,7 +427,7 @@ void MobileOpenGLGraphics::completeCache() restrict2
// debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, mImageCached);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
drawTriangleArrayfsCached(mVpCached);
mImageCached = 0;
@@ -457,7 +457,7 @@ void MobileOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
// Draw a textured quad.
drawRescaledQuad(image, imageRect.x, imageRect.y, dstX, dstY,
@@ -500,7 +500,7 @@ void MobileOpenGLGraphics::drawPatternInline(const Image *restrict const image,
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
@@ -565,7 +565,7 @@ void MobileOpenGLGraphics::drawRescaledPattern(const Image *
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
@@ -757,7 +757,7 @@ void MobileOpenGLGraphics::drawTileCollection(const ImageCollection *
debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
drawVertexes(vert->ogl);
}
}
@@ -860,7 +860,7 @@ void MobileOpenGLGraphics::drawTileVertexes(const ImageVertexes *
debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
drawVertexes(vert->ogl);
}
@@ -1023,7 +1023,7 @@ void MobileOpenGLGraphics::drawPoint(int x A_UNUSED, int y A_UNUSED) restrict2
void MobileOpenGLGraphics::drawPoint(int x, int y) restrict2
#endif // ANDROID
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
#ifdef ANDROID
@@ -1039,7 +1039,7 @@ void MobileOpenGLGraphics::drawPoint(int x, int y) restrict2
void MobileOpenGLGraphics::drawLine(int x1, int y1,
int x2, int y2) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
mShortVertArray[0] = static_cast<GLshort>(x1);
@@ -1060,43 +1060,41 @@ void MobileOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
drawRectangle(rect, true);
}
-void MobileOpenGLGraphics::setTexturingAndBlending(const bool enable) restrict2
+void MobileOpenGLGraphics::enableTexturingAndBlending() restrict2
{
- if (enable)
+ if (!mTexture)
{
- if (!mTexture)
- {
- mglEnable(OpenGLImageHelper::mTextureType);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- mTexture = true;
- }
+ mglEnable(OpenGLImageHelper::mTextureType);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ mTexture = true;
+ }
- if (!mAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
+ if (!mAlpha)
+ {
+ mglEnable(GL_BLEND);
+ mAlpha = true;
}
- else
+}
+
+void MobileOpenGLGraphics::disableTexturingAndBlending() restrict2
+{
+ mTextureBinded = 0;
+ if (mAlpha && !mColorAlpha)
{
- mTextureBinded = 0;
- if (mAlpha && !mColorAlpha)
- {
- mglDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
+ mglDisable(GL_BLEND);
+ mAlpha = false;
+ }
+ else if (!mAlpha && mColorAlpha)
+ {
+ mglEnable(GL_BLEND);
+ mAlpha = true;
+ }
- if (mTexture)
- {
- mglDisable(OpenGLImageHelper::mTextureType);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- mTexture = false;
- }
+ if (mTexture)
+ {
+ mglDisable(OpenGLImageHelper::mTextureType);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ mTexture = false;
}
}
@@ -1104,7 +1102,7 @@ void MobileOpenGLGraphics::drawRectangle(const Rect &restrict rect,
const bool filled) restrict2
{
BLOCK_START("Graphics::drawRectangle")
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
const GLshort x = static_cast<GLshort>(rect.x);
@@ -1164,7 +1162,7 @@ void MobileOpenGLGraphics::drawNet(const int x1, const int y1,
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
const GLshort xs1 = static_cast<GLshort>(x1);
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index 7bec1f26c..35deaa52c 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -340,7 +340,7 @@ void ModernOpenGLGraphics::drawImageInline(const Image *restrict const image,
debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture(GL_TEXTURE_2D, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
setColorAlpha(image->mAlpha);
@@ -426,7 +426,7 @@ void ModernOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
debugBindTexture(image);
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
@@ -472,7 +472,7 @@ void ModernOpenGLGraphics::drawPatternInline(const Image *restrict const image,
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
setColorAlpha(image->mAlpha);
@@ -535,7 +535,7 @@ void ModernOpenGLGraphics::drawRescaledPattern(const Image *
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
setColorAlpha(image->mAlpha);
@@ -704,7 +704,7 @@ void ModernOpenGLGraphics::drawTileCollection(const ImageCollection
*restrict const vertCol)
restrict2
{
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
/*
if (!vertCol)
{
@@ -821,7 +821,7 @@ void ModernOpenGLGraphics::drawTileVertexes(const ImageVertexes *
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
drawVertexes(vert->ogl);
@@ -912,7 +912,7 @@ void ModernOpenGLGraphics::popClipArea() restrict2
void ModernOpenGLGraphics::drawPoint(int x, int y) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
GLint vertices[] =
@@ -934,7 +934,7 @@ void ModernOpenGLGraphics::drawPoint(int x, int y) restrict2
void ModernOpenGLGraphics::drawLine(int x1, int y1,
int x2, int y2) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
GLint vertices[] =
@@ -956,7 +956,7 @@ void ModernOpenGLGraphics::drawLine(int x1, int y1,
void ModernOpenGLGraphics::drawRectangle(const Rect &restrict rect) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
const int x1 = rect.x + clipArea.xOffset;
@@ -985,7 +985,7 @@ void ModernOpenGLGraphics::drawRectangle(const Rect &restrict rect) restrict2
void ModernOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
const int x1 = rect.x + clipArea.xOffset;
@@ -1012,38 +1012,36 @@ void ModernOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
#endif // OPENGLERRORS
}
-void ModernOpenGLGraphics::setTexturingAndBlending(const bool enable) restrict2
+void ModernOpenGLGraphics::enableTexturingAndBlending() restrict2
{
- if (enable)
+ if (!mTextureDraw)
{
- if (!mTextureDraw)
- {
- mTextureDraw = true;
- mglUniform1f(mDrawTypeUniform, 1.0f);
- }
- if (!mAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
+ mTextureDraw = true;
+ mglUniform1f(mDrawTypeUniform, 1.0f);
}
- else
+ if (!mAlpha)
{
- if (mTextureDraw)
- {
- mTextureDraw = false;
- mglUniform1f(mDrawTypeUniform, 0.0f);
- }
- if (mAlpha && !mColorAlpha)
- {
- mglDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
+ mglEnable(GL_BLEND);
+ mAlpha = true;
+ }
+}
+
+void ModernOpenGLGraphics::disableTexturingAndBlending() restrict2
+{
+ if (mTextureDraw)
+ {
+ mTextureDraw = false;
+ mglUniform1f(mDrawTypeUniform, 0.0f);
+ }
+ if (mAlpha && !mColorAlpha)
+ {
+ mglDisable(GL_BLEND);
+ mAlpha = false;
+ }
+ else if (!mAlpha && mColorAlpha)
+ {
+ mglEnable(GL_BLEND);
+ mAlpha = true;
}
}
@@ -1059,7 +1057,7 @@ void ModernOpenGLGraphics::drawNet(const int x1, const int y1,
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
bindArrayBufferAndAttributes(mVbo);
const ClipRect &clipArea = mClipStack.top();
const GLint dx = clipArea.xOffset;
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index 73013773f..1ca5e851e 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -389,7 +389,7 @@ void NormalOpenGLGraphics::drawImageInline(const Image *restrict const image,
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
const SDL_Rect &imageRect = image->mBounds;
drawQuad(image, imageRect.x, imageRect.y,
@@ -632,7 +632,7 @@ void NormalOpenGLGraphics::completeCache() restrict2
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, mImageCached);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
drawQuadArrayfiCached(mVpCached);
@@ -667,7 +667,7 @@ void NormalOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
// Draw a textured quad.
drawRescaledQuad(image, imageRect.x, imageRect.y, dstX, dstY,
@@ -711,7 +711,7 @@ void NormalOpenGLGraphics::drawPatternInline(const Image *restrict const image,
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
@@ -805,7 +805,7 @@ void NormalOpenGLGraphics::drawRescaledPattern(const Image *
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
@@ -1096,7 +1096,7 @@ void NormalOpenGLGraphics::drawTileCollection(const ImageCollection
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
drawVertexes(vert->ogl);
}
}
@@ -1219,7 +1219,7 @@ void NormalOpenGLGraphics::drawTileVertexes(const ImageVertexes *
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
drawVertexes(vert->ogl);
}
@@ -1387,7 +1387,7 @@ void NormalOpenGLGraphics::popClipArea() restrict2
void NormalOpenGLGraphics::drawPoint(int x, int y) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
#ifdef ANDROID
@@ -1403,7 +1403,7 @@ void NormalOpenGLGraphics::drawPoint(int x, int y) restrict2
void NormalOpenGLGraphics::drawLine(int x1, int y1,
int x2, int y2) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
mFloatTexArray[0] = static_cast<float>(x1) + 0.5F;
@@ -1424,43 +1424,41 @@ void NormalOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
drawRectangle(rect, true);
}
-void NormalOpenGLGraphics::setTexturingAndBlending(const bool enable) restrict2
+void NormalOpenGLGraphics::enableTexturingAndBlending() restrict2
{
- if (enable)
+ if (!mTexture)
{
- if (!mTexture)
- {
- glEnable(OpenGLImageHelper::mTextureType);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- mTexture = true;
- }
+ glEnable(OpenGLImageHelper::mTextureType);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ mTexture = true;
+ }
- if (!mAlpha)
- {
- glEnable(GL_BLEND);
- mAlpha = true;
- }
+ if (!mAlpha)
+ {
+ glEnable(GL_BLEND);
+ mAlpha = true;
}
- else
+}
+
+void NormalOpenGLGraphics::disableTexturingAndBlending() restrict2
+{
+ mTextureBinded = 0;
+ if (mAlpha && !mColorAlpha)
{
- mTextureBinded = 0;
- if (mAlpha && !mColorAlpha)
- {
- glDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- glEnable(GL_BLEND);
- mAlpha = true;
- }
+ glDisable(GL_BLEND);
+ mAlpha = false;
+ }
+ else if (!mAlpha && mColorAlpha)
+ {
+ glEnable(GL_BLEND);
+ mAlpha = true;
+ }
- if (mTexture)
- {
- glDisable(OpenGLImageHelper::mTextureType);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- mTexture = false;
- }
+ if (mTexture)
+ {
+ glDisable(OpenGLImageHelper::mTextureType);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ mTexture = false;
}
}
@@ -1474,7 +1472,7 @@ void NormalOpenGLGraphics::drawRectangle(const Rect &restrict rect,
const float width = static_cast<float>(rect.width);
const float height = static_cast<float>(rect.height);
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
GLfloat vert[] =
@@ -1505,7 +1503,7 @@ void NormalOpenGLGraphics::drawNet(const int x1, const int y1,
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
const float xf1 = static_cast<float>(x1);
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index c5c18295d..2526c9feb 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -181,7 +181,7 @@ void NullOpenGLGraphics::drawImageInline(const Image *restrict const image,
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
const SDL_Rect &imageRect = image->mBounds;
drawQuad(image, imageRect.x, imageRect.y, dstX, dstY,
@@ -232,7 +232,7 @@ void NullOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
// Draw a textured quad.
drawRescaledQuad(image, imageRect.x, imageRect.y, dstX, dstY,
@@ -274,7 +274,7 @@ void NullOpenGLGraphics::drawPatternInline(const Image *restrict const image,
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
@@ -408,7 +408,7 @@ void NullOpenGLGraphics::drawRescaledPattern(const Image *restrict const image,
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
@@ -755,7 +755,7 @@ void NullOpenGLGraphics::drawTileCollection(const ImageCollection
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
drawVertexes(vert->ogl);
}
}
@@ -917,7 +917,7 @@ void NullOpenGLGraphics::drawTileVertexes(const ImageVertexes *
#endif // DEBUG_BIND_TEXTURE
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
drawVertexes(vert->ogl);
}
@@ -996,14 +996,14 @@ void NullOpenGLGraphics::popClipArea() restrict2
void NullOpenGLGraphics::drawPoint(int x A_UNUSED, int y A_UNUSED) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
}
void NullOpenGLGraphics::drawLine(int x1, int y1,
int x2, int y2) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
mFloatTexArray[0] = static_cast<float>(x1) + 0.5F;
@@ -1024,34 +1024,32 @@ void NullOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
drawRectangle(rect, true);
}
-void NullOpenGLGraphics::setTexturingAndBlending(const bool enable) restrict2
+void NullOpenGLGraphics::enableTexturingAndBlending() restrict2
{
- if (enable)
- {
- if (!mTexture)
- mTexture = true;
+ if (!mTexture)
+ mTexture = true;
- if (!mAlpha)
- mAlpha = true;
- }
- else
- {
- mTextureBinded = 0;
- if (mAlpha && !mColorAlpha)
- mAlpha = false;
- else if (!mAlpha && mColorAlpha)
- mAlpha = true;
-
- if (mTexture)
- mTexture = false;
- }
+ if (!mAlpha)
+ mAlpha = true;
+}
+
+void NullOpenGLGraphics::disableTexturingAndBlending() restrict2
+{
+ mTextureBinded = 0;
+ if (mAlpha && !mColorAlpha)
+ mAlpha = false;
+ else if (!mAlpha && mColorAlpha)
+ mAlpha = true;
+
+ if (mTexture)
+ mTexture = false;
}
void NullOpenGLGraphics::drawRectangle(const Rect &restrict rect A_UNUSED,
const bool filled A_UNUSED) restrict2
{
BLOCK_START("Graphics::drawRectangle")
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
#ifdef DEBUG_DRAW_CALLS
@@ -1068,7 +1066,7 @@ void NullOpenGLGraphics::drawNet(const int x1, const int y1,
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
const float xf1 = static_cast<float>(x1);
diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp
index 48d3ccd25..7a4fd4e1e 100644
--- a/src/render/openglgraphicsdef.hpp
+++ b/src/render/openglgraphicsdef.hpp
@@ -48,7 +48,9 @@ public:
static GLuint mTextureBinded;
protected:
- void setTexturingAndBlending(const bool enable) restrict2;
+ void enableTexturingAndBlending() restrict2;
+
+ void disableTexturingAndBlending() restrict2;
private:
void inline setColorAlpha(const float alpha) restrict2 A_INLINE;
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index 5eef25e2b..c5c10ad3d 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -181,7 +181,7 @@ void SafeOpenGLGraphics::drawImageInline(const Image *restrict const image,
setColorAlpha(image->mAlpha);
bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
const SDL_Rect &bounds = image->mBounds;
// Draw a textured quad.
@@ -236,7 +236,7 @@ void SafeOpenGLGraphics::drawImageCached(const Image *restrict const image,
setColorAlpha(image->mAlpha);
bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
const SDL_Rect &bounds = image->mBounds;
// Draw a textured quad.
@@ -264,7 +264,7 @@ void SafeOpenGLGraphics::drawPatternCached(const Image *restrict const image,
setColorAlpha(image->mAlpha);
bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
// Draw a set of textured rectangles
glBegin(GL_QUADS);
@@ -308,7 +308,7 @@ void SafeOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
setColorAlpha(image->mAlpha);
bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
// Draw a textured quad.
glBegin(GL_QUADS);
@@ -343,7 +343,7 @@ void SafeOpenGLGraphics::drawPatternInline(const Image *restrict const image,
setColorAlpha(image->mAlpha);
bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
// Draw a set of textured rectangles
glBegin(GL_QUADS);
@@ -383,7 +383,7 @@ void SafeOpenGLGraphics::drawRescaledPattern(const Image *restrict const image,
setColorAlpha(image->mAlpha);
bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- setTexturingAndBlending(true);
+ enableTexturingAndBlending();
// Draw a set of textured rectangles
glBegin(GL_QUADS);
@@ -583,7 +583,7 @@ void SafeOpenGLGraphics::popClipArea() restrict2
void SafeOpenGLGraphics::drawPoint(int x, int y) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
glBegin(GL_POINTS);
@@ -595,7 +595,7 @@ void SafeOpenGLGraphics::drawNet(const int x1, const int y1,
const int x2, const int y2,
const int width, const int height) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
glBegin(GL_LINES);
@@ -620,7 +620,7 @@ void SafeOpenGLGraphics::drawNet(const int x1, const int y1,
void SafeOpenGLGraphics::drawLine(int x1, int y1,
int x2, int y2) restrict2
{
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
glBegin(GL_LINES);
@@ -639,41 +639,39 @@ void SafeOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
drawRectangle(rect, true);
}
-void SafeOpenGLGraphics::setTexturingAndBlending(const bool enable) restrict2
+void SafeOpenGLGraphics::enableTexturingAndBlending() restrict2
{
- if (enable)
+ if (!mTexture)
{
- if (!mTexture)
- {
- glEnable(SafeOpenGLImageHelper::mTextureType);
- mTexture = true;
- }
+ glEnable(SafeOpenGLImageHelper::mTextureType);
+ mTexture = true;
+ }
- if (!mAlpha)
- {
- glEnable(GL_BLEND);
- mAlpha = true;
- }
+ if (!mAlpha)
+ {
+ glEnable(GL_BLEND);
+ mAlpha = true;
}
- else
+}
+
+void SafeOpenGLGraphics::disableTexturingAndBlending() restrict2
+{
+ mTextureBinded = 0;
+ if (mAlpha && !mColorAlpha)
{
- mTextureBinded = 0;
- if (mAlpha && !mColorAlpha)
- {
- glDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- glEnable(GL_BLEND);
- mAlpha = true;
- }
+ glDisable(GL_BLEND);
+ mAlpha = false;
+ }
+ else if (!mAlpha && mColorAlpha)
+ {
+ glEnable(GL_BLEND);
+ mAlpha = true;
+ }
- if (mTexture)
- {
- glDisable(SafeOpenGLImageHelper::mTextureType);
- mTexture = false;
- }
+ if (mTexture)
+ {
+ glDisable(SafeOpenGLImageHelper::mTextureType);
+ mTexture = false;
}
}
@@ -683,7 +681,7 @@ void SafeOpenGLGraphics::drawRectangle(const Rect &restrict rect,
BLOCK_START("Graphics::drawRectangle")
const float offset = filled ? 0 : 0.5F;
- setTexturingAndBlending(false);
+ disableTexturingAndBlending();
restoreColor();
glBegin(filled ? GL_QUADS : GL_LINE_LOOP);