summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tiletex.cc
diff options
context:
space:
mode:
authorEnne Walker <ennewalker@users.sourceforge.net>2009-12-19 19:07:58 -0500
committerEnne Walker <ennewalker@users.sourceforge.net>2009-12-23 23:17:11 -0500
commit5b9916a319a570598c8cd54e916eb10dab0eb916 (patch)
treea07ff677e778020e280d513f6d512b355422e379 /crawl-ref/source/tiletex.cc
parent4b8c9fc0252de2891aede359b39dd0c44ee743ed (diff)
downloadcrawl-ref-5b9916a319a570598c8cd54e916eb10dab0eb916.tar.gz
crawl-ref-5b9916a319a570598c8cd54e916eb10dab0eb916.zip
Fixing power-of-two image loading issue.
If any tile image was a power of two, it would use a different path to load and swap R and B.
Diffstat (limited to 'crawl-ref/source/tiletex.cc')
-rw-r--r--crawl-ref/source/tiletex.cc39
1 files changed, 19 insertions, 20 deletions
diff --git a/crawl-ref/source/tiletex.cc b/crawl-ref/source/tiletex.cc
index ec65f779a1..804408ec0d 100644
--- a/crawl-ref/source/tiletex.cc
+++ b/crawl-ref/source/tiletex.cc
@@ -81,30 +81,29 @@ bool GenericTexture::load_texture(const char *filename,
GLenum texture_format;
if (bpp == 4)
{
- if (new_width != img->w || new_height != img->h)
- {
- SDL_LockSurface(img);
- pixels = new unsigned char[4 * new_width * new_height];
- memset(pixels, 0, 4 * new_width * new_height);
+ // Even if the size is the same, still go through
+ // SDL_GetRGBA to put the image in the right format.
+ SDL_LockSurface(img);
+ pixels = new unsigned char[4 * new_width * new_height];
+ memset(pixels, 0, 4 * new_width * new_height);
- int dest = 0;
- for (int y = 0; y < img->h; y++)
+ int dest = 0;
+ for (int y = 0; y < img->h; y++)
+ {
+ for (int x = 0; x < img->w; x++)
{
- for (int x = 0; x < img->w; x++)
- {
- unsigned char *p = ((unsigned char*)img->pixels
- + y * img->pitch + x * bpp);
- unsigned int pixel = *(unsigned int*)p;
- SDL_GetRGBA(pixel, img->format, &pixels[dest],
- &pixels[dest+1], &pixels[dest+2],
- &pixels[dest+3]);
- dest += 4;
- }
- dest += 4 * (new_width - img->w);
+ unsigned char *p = ((unsigned char*)img->pixels
+ + y * img->pitch + x * bpp);
+ unsigned int pixel = *(unsigned int*)p;
+ SDL_GetRGBA(pixel, img->format, &pixels[dest],
+ &pixels[dest+1], &pixels[dest+2],
+ &pixels[dest+3]);
+ dest += 4;
}
-
- SDL_UnlockSurface(img);
+ dest += 4 * (new_width - img->w);
}
+
+ SDL_UnlockSurface(img);
texture_format = GL_RGBA;
}
else if (bpp == 3)