summaryrefslogtreecommitdiff
path: root/src/resources/safeopenglimagehelper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/safeopenglimagehelper.cpp')
-rw-r--r--src/resources/safeopenglimagehelper.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/resources/safeopenglimagehelper.cpp b/src/resources/safeopenglimagehelper.cpp
index f43351d7c..b1daf05e9 100644
--- a/src/resources/safeopenglimagehelper.cpp
+++ b/src/resources/safeopenglimagehelper.cpp
@@ -48,7 +48,7 @@
#ifndef SDL_BYTEORDER
#error missing SDL_endian.h
-#endif
+#endif // SDL_BYTEORDER
int SafeOpenGLImageHelper::mTextureType = 0;
int SafeOpenGLImageHelper::mInternalTextureType = GL_RGBA8;
@@ -163,10 +163,11 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else
+#else // USE_SDL2
+
// Make sure the alpha channel is not used, but copied to destination
SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif
+#endif // USE_SDL2
// Determine 32-bit masks based on byte order
uint32_t rmask, gmask, bmask, amask;
@@ -175,12 +176,13 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
if (tmpImage->format->BitsPerPixel != 32
|| realWidth != width || realHeight != height
@@ -191,7 +193,8 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface
SDL_Surface *oldImage = tmpImage;
#ifdef USE_SDL2
SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif
+#endif // USE_SDL2
+
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);
@@ -214,10 +217,11 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else
+#else // USE_SDL2
+
// Make sure the alpha channel is not used, but copied to destination
SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif
+#endif // USE_SDL2
// Determine 32-bit masks based on byte order
uint32_t rmask, gmask, bmask, amask;
@@ -226,12 +230,13 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
if (tmpImage->format->BitsPerPixel != 32
|| rmask != tmpImage->format->Rmask
@@ -241,7 +246,8 @@ SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
SDL_Surface *oldImage = tmpImage;
#ifdef USE_SDL2
SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif
+#endif // USE_SDL2
+
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
32, rmask, gmask, bmask, amask);
@@ -353,7 +359,7 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
}
#ifndef ANDROID
glTexParameteri(mTextureType, GL_TEXTURE_MAX_LEVEL, 0);
-#endif
+#endif // ANDROID
glTexImage2D(mTextureType, 0, mInternalTextureType,
tmpImage->w, tmpImage->h,
@@ -368,7 +374,7 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
mglLabelObject(GL_TEXTURE, texture, strlen(text), text);
}
*/
-#endif
+#endif // DEBUG_OPENGL
/*
GLint compressed;
@@ -382,7 +388,7 @@ Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
#ifdef DEBUG_OPENGL_LEAKS
textures_count ++;
-#endif
+#endif // DEBUG_OPENGL_LEAKS
if (SDL_MUSTLOCK(tmpImage))
SDL_UnlockSurface(tmpImage);
@@ -425,12 +431,13 @@ SDL_Surface *SafeOpenGLImageHelper::create32BitSurface(int width,
const int gmask = 0x00ff0000;
const int bmask = 0x0000ff00;
const int amask = 0x000000ff;
-#else
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
const int rmask = 0x000000ff;
const int gmask = 0x0000ff00;
const int bmask = 0x00ff0000;
const int amask = 0xff000000;
-#endif
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
width = powerOfTwo(width);
height = powerOfTwo(height);