-#include <msp/gl/extensions/arb_depth_buffer_float.h>
-#include <msp/gl/extensions/arb_depth_texture.h>
-#include <msp/gl/extensions/arb_texture_float.h>
-#include <msp/gl/extensions/arb_texture_rg.h>
-#include <msp/gl/extensions/ext_texture_srgb.h>
-#include <msp/gl/extensions/oes_required_internalformat.h>
-#include <msp/gl/extensions/oes_texture_stencil8.h>
-#include <msp/io/print.h>
#include <msp/strings/format.h>
#include "pixelformat.h"
return static_cast<PixelFormat>(comp | get_type_size(type)<<8 | (type&0x300)<<4 | normalized*0x4000 | srgb*0x8000);
}
-void require_pixelformat(PixelFormat pf)
-{
- /* 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");
- }
-}
-
-GLenum get_gl_components(PixelComponents comp)
-{
- switch(comp)
- {
- case RED: return GL_RED;
- case RG: return GL_RG;
- case RGB: return GL_RGB;
- case RGBA: return GL_RGBA;
- case DEPTH_COMPONENT: return GL_DEPTH_COMPONENT;
- case STENCIL_INDEX: return GL_STENCIL_INDEX;
- default: throw invalid_argument("get_gl_components");
- }
-}
-
-GLenum get_gl_pixelformat(PixelFormat pf)
-{
- switch(pf)
- {
- case R8: return GL_R8;
- case R16F: return GL_R16F;
- case R32F: return GL_R32F;
- case RG8: return GL_RG8;
- case RG16F: return GL_RG16F;
- case RG32F: return GL_RG32F;
- case RGB8: return GL_RGB8;
- case RGB16F: return GL_RGB16F;
- case RGB32F: return GL_RGB32F;
- case RGBA8: return GL_RGBA8;
- case RGBA16F: return GL_RGBA16F;
- case RGBA32F: return GL_RGBA32F;
- case SRGB8: return GL_SRGB8;
- case SRGB8_ALPHA8: return GL_SRGB8_ALPHA8;
- case DEPTH_COMPONENT16: return GL_DEPTH_COMPONENT16;
- case DEPTH_COMPONENT24: return GL_DEPTH_COMPONENT24;
- case DEPTH_COMPONENT32: return GL_DEPTH_COMPONENT32;
- case DEPTH_COMPONENT32F: return GL_DEPTH_COMPONENT32F;
- case STENCIL_INDEX8: return GL_STENCIL_INDEX8;
- default: throw invalid_argument("get_gl_pixelformat");
- }
-}
-
} // namespace GL
} // namespace Msp