summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-07-22 21:08:05 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-07-23 08:21:40 +0200
commit719ae10eca9083058dd5734ffc7aaa51c5fc9f98 (patch)
tree33498bc5c10c307a618b4147c3cefb461540786e /src/resources
parente26642fbd61fbc842d6f88c6f078a7ed16b14389 (diff)
downloadmana-719ae10eca9083058dd5734ffc7aaa51c5fc9f98.tar.gz
mana-719ae10eca9083058dd5734ffc7aaa51c5fc9f98.tar.bz2
mana-719ae10eca9083058dd5734ffc7aaa51c5fc9f98.tar.xz
mana-719ae10eca9083058dd5734ffc7aaa51c5fc9f98.zip
Fixed indentation of Image::_GLload
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/image.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 975bd647..9a3e2ba2 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -439,101 +439,101 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
#ifdef USE_OPENGL
Image *Image::_GLload(SDL_Surface *tmpImage)
{
- // Flush current error flag.
- glGetError();
+ // Flush current error flag.
+ glGetError();
- int width = tmpImage->w;
- int height = tmpImage->h;
- int realWidth = powerOfTwo(width);
- int realHeight = powerOfTwo(height);
+ int width = tmpImage->w;
+ int height = tmpImage->h;
+ int realWidth = powerOfTwo(width);
+ int realHeight = powerOfTwo(height);
- if (realWidth < width || realHeight < height)
- {
- logger->log("Warning: image too large, cropping to %dx%d texture!",
- tmpImage->w, tmpImage->h);
- }
+ if (realWidth < width || realHeight < height)
+ {
+ logger->log("Warning: image too large, cropping to %dx%d texture!",
+ tmpImage->w, tmpImage->h);
+ }
- // Make sure the alpha channel is not used, but copied to destination
- SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
+ // Make sure the alpha channel is not used, but copied to destination
+ SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
- // Determine 32-bit masks based on byte order
- Uint32 rmask, gmask, bmask, amask;
+ // Determine 32-bit masks based on byte order
+ Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
+ rmask = 0xff000000;
+ gmask = 0x00ff0000;
+ bmask = 0x0000ff00;
+ amask = 0x000000ff;
#else
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0xff000000;
+ rmask = 0x000000ff;
+ gmask = 0x0000ff00;
+ bmask = 0x00ff0000;
+ amask = 0xff000000;
#endif
- SDL_Surface *oldImage = tmpImage;
- tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
- 32, rmask, gmask, bmask, amask);
+ SDL_Surface *oldImage = tmpImage;
+ tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
+ 32, rmask, gmask, bmask, amask);
- if (!tmpImage)
- {
- logger->log("Error, image convert failed: out of memory");
- return NULL;
- }
+ if (!tmpImage)
+ {
+ logger->log("Error, image convert failed: out of memory");
+ return NULL;
+ }
- SDL_BlitSurface(oldImage, NULL, tmpImage, NULL);
+ SDL_BlitSurface(oldImage, NULL, tmpImage, NULL);
- GLuint texture;
- glGenTextures(1, &texture);
- OpenGLGraphics::bindTexture(mTextureType, texture);
+ GLuint texture;
+ glGenTextures(1, &texture);
+ OpenGLGraphics::bindTexture(mTextureType, texture);
- if (SDL_MUSTLOCK(tmpImage))
- SDL_LockSurface(tmpImage);
+ if (SDL_MUSTLOCK(tmpImage))
+ SDL_LockSurface(tmpImage);
- glTexImage2D(
- mTextureType, 0, 4,
- tmpImage->w, tmpImage->h,
- 0, GL_RGBA, GL_UNSIGNED_BYTE,
- tmpImage->pixels);
+ glTexImage2D(
+ mTextureType, 0, 4,
+ tmpImage->w, tmpImage->h,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ tmpImage->pixels);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- if (SDL_MUSTLOCK(tmpImage))
- SDL_UnlockSurface(tmpImage);
+ if (SDL_MUSTLOCK(tmpImage))
+ SDL_UnlockSurface(tmpImage);
- SDL_FreeSurface(tmpImage);
+ SDL_FreeSurface(tmpImage);
- GLenum error = glGetError();
- if (error)
+ GLenum error = glGetError();
+ if (error)
+ {
+ std::string errmsg = "Unknown error";
+ switch (error)
{
- std::string errmsg = "Unknown error";
- switch (error)
- {
- case GL_INVALID_ENUM:
- errmsg = "GL_INVALID_ENUM";
- break;
- case GL_INVALID_VALUE:
- errmsg = "GL_INVALID_VALUE";
- break;
- case GL_INVALID_OPERATION:
- errmsg = "GL_INVALID_OPERATION";
- break;
- case GL_STACK_OVERFLOW:
- errmsg = "GL_STACK_OVERFLOW";
- break;
- case GL_STACK_UNDERFLOW:
- errmsg = "GL_STACK_UNDERFLOW";
- break;
- case GL_OUT_OF_MEMORY:
- errmsg = "GL_OUT_OF_MEMORY";
- break;
- }
- logger->log("Error: Image GL import failed: %s", errmsg.c_str());
- return NULL;
+ case GL_INVALID_ENUM:
+ errmsg = "GL_INVALID_ENUM";
+ break;
+ case GL_INVALID_VALUE:
+ errmsg = "GL_INVALID_VALUE";
+ break;
+ case GL_INVALID_OPERATION:
+ errmsg = "GL_INVALID_OPERATION";
+ break;
+ case GL_STACK_OVERFLOW:
+ errmsg = "GL_STACK_OVERFLOW";
+ break;
+ case GL_STACK_UNDERFLOW:
+ errmsg = "GL_STACK_UNDERFLOW";
+ break;
+ case GL_OUT_OF_MEMORY:
+ errmsg = "GL_OUT_OF_MEMORY";
+ break;
}
+ logger->log("Error: Image GL import failed: %s", errmsg.c_str());
+ return NULL;
+ }
- return new Image(texture, width, height, realWidth, realHeight);
+ return new Image(texture, width, height, realWidth, realHeight);
}
void Image::setLoadAsOpenGL(bool useOpenGL)