X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Fpixelformat_backend.cpp;h=9cf796479c37d6ac7077aef33abe1255da16b4ac;hb=8a8cce8ef4ee28b3572a72958b8b407759f9f826;hp=7e2a61ea536655ee8b5f33031f18ef57abe8ce59;hpb=d279ad43486e287d4fe7e759e31b026949021260;p=libs%2Fgl.git diff --git a/source/backends/opengl/pixelformat_backend.cpp b/source/backends/opengl/pixelformat_backend.cpp index 7e2a61ea..9cf79647 100644 --- a/source/backends/opengl/pixelformat_backend.cpp +++ b/source/backends/opengl/pixelformat_backend.cpp @@ -11,9 +11,34 @@ 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 @@ -106,5 +131,10 @@ unsigned get_gl_pixelformat(PixelFormat pf) } } +const int *get_gl_swizzle(ComponentSwizzle swiz) +{ + return swizzle_orders+4*swiz; +} + } // namespace GL } // namespace Msp