]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/pixelformat.cpp
Add a swizzle mode for presenting an RGBA texture as RGB
[libs/gl.git] / source / core / pixelformat.cpp
index 2ee5af7de6cf7f2d073fdeaa065a6218b4ac6c51..6e7621882fef8eae4e595cd07e004a34b8e567bf 100644 (file)
@@ -110,6 +110,10 @@ PixelComponents swizzle_components(PixelComponents comp, ComponentSwizzle swiz)
                return BGR;
        else if(comp==RGBA && swiz==RGB_TO_BGR)
                return BGRA;
+       else if(comp==RGBA && swiz==RGBA_TO_RGB)
+               return RGB;
+       else if(comp==BGRA && swiz==RGBA_TO_RGB)
+               return BGR;
        else
                throw invalid_argument("swizzle_components");
 }
@@ -126,6 +130,10 @@ PixelComponents unswizzle_components(PixelComponents comp, ComponentSwizzle swiz
                return RGB;
        else if(comp==BGRA && swiz==RGB_TO_BGR)
                return RGBA;
+       else if(comp==RGB && swiz==RGBA_TO_RGB)
+               return RGBA;
+       else if(comp==BGR && swiz==RGBA_TO_RGB)
+               return BGRA;
        else
                throw invalid_argument("swizzle_components");
 }