]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/pixelformat_backend.cpp
Move swizzling modes to pixelformat.h
[libs/gl.git] / source / backends / opengl / pixelformat_backend.cpp
index 7e2a61ea536655ee8b5f33031f18ef57abe8ce59..79669ba999a75a4c9adb172153d3c10e35b0e74a 100644 (file)
 
 using namespace std;
 
+namespace {
+
+int 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_BLUE, GL_GREEN, GL_RED, GL_ALPHA
+};
+
+}
+
 namespace Msp {
 namespace GL {
 
+ComponentSwizzle get_required_swizzle(PixelComponents comp)
+{
+       switch(comp)
+       {
+       case BGR: return RGB_TO_BGR;
+       case BGRA: return RGB_TO_BGR;
+       case LUMINANCE: return R_TO_LUMINANCE;
+       case LUMINANCE_ALPHA: return RG_TO_LUMINANCE_ALPHA;
+       default: return NO_SWIZZLE;
+       }
+}
+
 void require_pixelformat(PixelFormat pf)
 {
        /* TODO These checks are only accurate for textures.  On OpenGL ES some
@@ -106,5 +130,10 @@ unsigned get_gl_pixelformat(PixelFormat pf)
        }
 }
 
+const int *get_gl_swizzle(ComponentSwizzle swiz)
+{
+       return swizzle_orders+4*swiz;
+}
+
 } // namespace GL
 } // namespace Msp