- /* TODO These checks are only accurate for textures. On OpenGL ES some
- formats are allowed for render buffers earlier than textures. In particular
- it's possible to create a 16-bit depth renderbuffer on OpenGL ES 2.0 but
- depth textures are only available with 3.0 or the OES_depth_texture
- extension.*/
- switch(pf)
- {
- case RGB8:
- case RGBA8:
- { static Require _req(OES_required_internalformat); }
- break;
- case R8:
- case RG8:
- { static Require _req(ARB_texture_rg); }
- break;
- case R16F:
- case R32F:
- case RG16F:
- case RG32F:
- { static Require _req(ARB_texture_rg); }
- { static Require _req(ARB_texture_float); }
- break;
- case RGB16F:
- case RGB32F:
- case RGBA16F:
- case RGBA32F:
- { static Require _req(ARB_texture_float); }
- break;
- case SRGB8:
- case SRGB8_ALPHA8:
- { static Require _req(EXT_texture_sRGB); }
- break;
- case DEPTH_COMPONENT16:
- case DEPTH_COMPONENT24:
- case DEPTH_COMPONENT32:
- { static Require _req(ARB_depth_texture); }
- { static Require _req(OES_required_internalformat); }
- break;
- case DEPTH_COMPONENT32F:
- { static Require _req(ARB_depth_buffer_float); }
- break;
- case STENCIL_INDEX8:
- { static Require _req(OES_texture_stencil8); }
- break;
- default:
- throw invalid_argument("require_pixelformat");
- }
+ if(swiz==NO_SWIZZLE)
+ return comp;
+ else if(comp==LUMINANCE && swiz==R_TO_LUMINANCE)
+ return RED;
+ else if(comp==LUMINANCE_ALPHA && swiz==RG_TO_LUMINANCE_ALPHA)
+ return RG;
+ else if(comp==BGR && swiz==RGB_TO_BGR)
+ 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");