diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-05-21 22:15:35 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-05-21 22:15:35 +0200 |
commit | 98f0d881978eb1c35c9bc4ab7d951e22f873102b (patch) | |
tree | 9b966785139dcf1a9e85cb8acf7c358652753d03 /engine/texturesdl.cpp | |
parent | 267bebfc227c94f543a39e2aa75fb101bc06932e (diff) |
Fixed RGB vs BGR in texture loading.
Diffstat (limited to 'engine/texturesdl.cpp')
-rw-r--r-- | engine/texturesdl.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/engine/texturesdl.cpp b/engine/texturesdl.cpp index 8e112ef..bab760b 100644 --- a/engine/texturesdl.cpp +++ b/engine/texturesdl.cpp @@ -1,6 +1,6 @@ -#include <iostream> #include <stdexcept> #include <SDL/SDL_image.h> +#include <SDL/SDL_opengl.h> #include "texturesdl.h" TextureSDL::TextureSDL(const char* filename) { @@ -8,7 +8,13 @@ TextureSDL::TextureSDL(const char* filename) { width = image->w; height = image->h; - byte_per_pixel = image->format->BytesPerPixel; + + if(image->format->BytesPerPixel == 4) { + format = image->format->Bshift ? GL_RGBA : GL_BGRA; + } else { + format = image->format->Bshift ? GL_RGB : GL_BGR; + } + data = (unsigned char*)image->pixels; build(); |