]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture.cpp
Support BGR and BGRA as texture formats through swizzling
[libs/gl.git] / source / texture.cpp
index f0c55999250263f641e546341e22b7545177748b..cf32ca301cab4bf10bc513ad65de9546c1b757e4 100644 (file)
@@ -18,7 +18,8 @@ int Texture::swizzle_orders[] =
 {
        GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA,
        GL_RED, GL_RED, GL_RED, GL_ONE,
-       GL_RED, GL_RED, GL_RED, GL_GREEN
+       GL_RED, GL_RED, GL_RED, GL_GREEN,
+       GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA
 };
 
 Texture::Texture(GLenum t, ResourceManager *m):
@@ -60,6 +61,14 @@ void Texture::set_internal_format(PixelFormat fmt)
                comp = RG;
                swiz = RG_TO_LUMINANCE_ALPHA;
                break;
+       case BGR:
+               comp = RGB;
+               swiz = RGB_TO_BGR;
+               break;
+       case BGRA:
+               comp = RGBA;
+               swiz = RGB_TO_BGR;
+               break;
        default:;
        }
 
@@ -73,7 +82,7 @@ void Texture::set_internal_format(PixelFormat fmt)
 
 PixelComponents Texture::get_upload_components(PixelComponents comp) const
 {
-       if(comp==LUMINANCE || comp==LUMINANCE_ALPHA)
+       if(comp==LUMINANCE || comp==LUMINANCE_ALPHA || comp==BGR || comp==BGRA)
                return get_components(ifmt);
        else
                return comp;