X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fpixelformat.h;h=dde8594e723793a001c6166e575f18f8119aa86d;hp=c9d813cef1bff430200587996f864be8d089e609;hb=33b6ca811172d402fc891eeed9cd2a5edc28d61d;hpb=a60b558e1c327fd2e2600ad2551dc0ac648761f2 diff --git a/source/core/pixelformat.h b/source/core/pixelformat.h index c9d813ce..dde8594e 100644 --- a/source/core/pixelformat.h +++ b/source/core/pixelformat.h @@ -19,81 +19,97 @@ namespace Msp { namespace GL { +/** +Identifies the components of a pixel, without type information. The values +are bitfields laid as follows: + +_grs dccc + │││ │ └╴Number of components + │││ └───╴Depth flag + ││└─────╴Stencil flag + │└──────╴Reverse order flag + └───────╴Grayscale flag + +This information is presented for internal documentation purposes only; it is +inadvisable for programs to rely on it. +*/ enum PixelComponents { - RED = GL_RED, - RG = GL_RG, - RGB = GL_RGB, - RGBA = GL_RGBA, - BGR = GL_BGR, - BGRA = GL_BGRA, - LUMINANCE = GL_LUMINANCE, - LUMINANCE_ALPHA = GL_LUMINANCE_ALPHA, - DEPTH_COMPONENT = GL_DEPTH_COMPONENT, - STENCIL_INDEX = GL_STENCIL_INDEX + RED = 0x01, + RG = 0x02, + RGB = 0x03, + RGBA = 0x04, + DEPTH_COMPONENT = 0x09, + STENCIL_INDEX = 0x11, + BGR = 0x23, + BGRA = 0x24, + LUMINANCE = 0x41, + LUMINANCE_ALPHA = 0x42 }; +/** +Identifies a pixel format, with components and type. The values are bitfields +laid as follows: + +tnfg ssss cccc cccc +││││ │ └╴Components (see PixelComponents) +││││ └──────────╴Size of one component (bytes) +│││└───────────────╴Signed flag +││└────────────────╴Floating-point flag +│└─────────────────╴Normalized flag +└──────────────────╴sRGB flag + +This information is presented for internal documentation purposes only; it is +inadvisable for programs to rely on it. +*/ enum PixelFormat { - R8 = GL_R8, - R16F = GL_R16F, - R32F = GL_R32F, - RG8 = GL_RG8, - RG16F = GL_RG16F, - RG32F = GL_RG32F, - RGB8 = GL_RGB8, - RGB16F = GL_RGB16F, - RGB32F = GL_RGB32F, - RGBA8 = GL_RGBA8, - RGBA16F = GL_RGBA16F, - RGBA32F = GL_RGBA32F, - SRGB8 = GL_SRGB8, - SRGB8_ALPHA8 = GL_SRGB8_ALPHA8, - BGR8 = 200000, - BGRA8 = 200001, - SBGR8 = 200002, - SBGR8_ALPHA8 = 200003, - LUMINANCE8 = GL_LUMINANCE8, - LUMINANCE8_ALPHA8 = GL_LUMINANCE8_ALPHA8, - DEPTH_COMPONENT16 = GL_DEPTH_COMPONENT16, - DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24, - DEPTH_COMPONENT32 = GL_DEPTH_COMPONENT32, - DEPTH_COMPONENT32F = GL_DEPTH_COMPONENT32F, - STENCIL_INDEX8 = GL_STENCIL_INDEX8 + R8 = 0x4100|RED, + R16F = 0x3200|RED, + R32F = 0x3400|RED, + RG8 = 0x4100|RG, + RG16F = 0x3200|RG, + RG32F = 0x3400|RG, + RGB8 = 0x4100|RGB, + RGB16F = 0x3200|RGB, + RGB32F = 0x3400|RGB, + RGBA8 = 0x4100|RGBA, + RGBA16F = 0x3200|RGBA, + RGBA32F = 0x3400|RGBA, + SRGB8 = 0xC100|RGB, + SRGB8_ALPHA8 = 0xC100|RGBA, + BGR8 = 0x4100|BGR, + BGRA8 = 0x4100|BGRA, + SBGR8 = 0xC100|BGR, + SBGR8_ALPHA8 = 0xC100|BGRA, + LUMINANCE8 = 0x4100|LUMINANCE, + LUMINANCE8_ALPHA8 = 0x4100|LUMINANCE_ALPHA, + DEPTH_COMPONENT16 = 0x4200|DEPTH_COMPONENT, + DEPTH_COMPONENT24 = 0x4300|DEPTH_COMPONENT, + DEPTH_COMPONENT32 = 0x4400|DEPTH_COMPONENT, + DEPTH_COMPONENT32F = 0x3400|DEPTH_COMPONENT, + STENCIL_INDEX8 = 0x0100|STENCIL_INDEX }; void operator>>(const LexicalConverter &, PixelComponents &); void operator>>(const LexicalConverter &, PixelFormat &); -DEPRECATED PixelComponents pixelformat_from_graphics(Graphics::PixelFormat); -DEPRECATED PixelComponents storage_pixelformat_from_graphics(Graphics::PixelFormat, bool); +PixelComponents components_from_graphics(Graphics::PixelFormat); PixelFormat pixelformat_from_image(const Graphics::Image &); PixelFormat make_pixelformat(PixelComponents, DataType, bool = false); -DEPRECATED PixelFormat get_base_pixelformat(PixelFormat); -PixelComponents get_components(PixelFormat); -DEPRECATED PixelFormat get_default_sized_pixelformat(PixelComponents); -DEPRECATED PixelFormat get_srgb_pixelformat(PixelFormat); - -unsigned get_component_count(PixelComponents); -inline unsigned get_component_count(PixelFormat f) -{ return get_component_count(get_components(f)); } - -DataType get_component_type(PixelFormat); -inline unsigned get_component_size(PixelFormat f) -{ return get_type_size(get_component_type(f)); } - -bool is_srgb(PixelFormat); - -unsigned get_pixel_size(PixelFormat); +inline PixelComponents get_components(PixelFormat f) { return static_cast(f&0xFF); } +inline unsigned get_component_count(PixelComponents c) { return c&7; } +inline unsigned get_component_count(PixelFormat f) { return get_component_count(get_components(f)); } +inline DataType get_component_type(PixelFormat f) { return static_cast((f&0xF00)>>8 | (f&0x3000)>>4); } +inline unsigned get_component_size(PixelFormat f) { return get_type_size(get_component_type(f)); } +inline bool is_srgb(PixelFormat f) { return f&0x8000; } +inline unsigned get_pixel_size(PixelFormat f) { return get_component_count(f)*get_type_size(get_component_type(f)); } void require_pixelformat(PixelFormat); -DEPRECATED inline PixelFormat get_sized_pixelformat(PixelComponents c, unsigned s = 1) -{ return make_pixelformat(c, (s==2 ? HALF_FLOAT : s==4 ? FLOAT : UNSIGNED_BYTE)); } - -DEPRECATED inline PixelComponents get_unsized_pixelformat(PixelFormat f) -{ return get_components(f); } +GLenum get_gl_components(PixelComponents); +GLenum get_gl_pixelformat(PixelFormat); } // namespace GL } // namespace Msp