]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/pixelformat_backend.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / backends / opengl / pixelformat_backend.cpp
index ee1a2070a251ff1f858f0e5634bd57188d208433..9cf796479c37d6ac7077aef33abe1255da16b4ac 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,
+       GL_RED, GL_GREEN, GL_BLUE, GL_ONE
+};
+
+}
+
 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
@@ -65,7 +90,7 @@ void require_pixelformat(PixelFormat pf)
        }
 }
 
-GLenum get_gl_components(PixelComponents comp)
+unsigned get_gl_components(PixelComponents comp)
 {
        switch(comp)
        {
@@ -79,7 +104,7 @@ GLenum get_gl_components(PixelComponents comp)
        }
 }
 
-GLenum get_gl_pixelformat(PixelFormat pf)
+unsigned get_gl_pixelformat(PixelFormat pf)
 {
        switch(pf)
        {
@@ -106,5 +131,10 @@ GLenum get_gl_pixelformat(PixelFormat pf)
        }
 }
 
+const int *get_gl_swizzle(ComponentSwizzle swiz)
+{
+       return swizzle_orders+4*swiz;
+}
+
 } // namespace GL
 } // namespace Msp