X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fpixelformat.h;h=b2d1b9cd7948d069233e71cb4722043df6120f83;hb=8e58fc4da8443cb67fe4cd70d6f68de2be73011d;hp=2f6038459bb7b345d610a1875cfa9e91a5cce38f;hpb=8653af6d620206c1a8bab284721256e9ea4e3b74;p=libs%2Fgl.git diff --git a/source/core/pixelformat.h b/source/core/pixelformat.h index 2f603845..b2d1b9cd 100644 --- a/source/core/pixelformat.h +++ b/source/core/pixelformat.h @@ -3,15 +3,15 @@ #include #include -#include "gl.h" #include "datatype.h" namespace Msp { namespace GL { /** -Identifies the components of a pixel, without type information. The values -are bitfields laid as follows: +Identifies the components of a pixel, without type information. + +The values are bitfields laid as follows: _grs dccc │││ │ └╴Number of components @@ -21,7 +21,7 @@ _grs dccc └───────╴Grayscale flag This information is presented for internal documentation purposes only; it is -inadvisable for programs to rely on it. +inadvisable for applications to rely on it. */ enum PixelComponents { @@ -38,8 +38,20 @@ enum PixelComponents }; /** -Identifies a pixel format, with components and type. The values are bitfields -laid as follows: +Describes a mapping from one set of components to another. +*/ +enum ComponentSwizzle +{ + NO_SWIZZLE, + R_TO_LUMINANCE, + RG_TO_LUMINANCE_ALPHA, + RGB_TO_BGR +}; + +/** +Identifies a pixel format, with components and type. + +The values are bitfields laid as follows: tnfg ssss cccc cccc ││││ │ └╴Components (see PixelComponents) @@ -50,7 +62,7 @@ tnfg ssss cccc cccc └──────────────────╴sRGB flag This information is presented for internal documentation purposes only; it is -inadvisable for programs to rely on it. +inadvisable for applications to rely on it. */ enum PixelFormat { @@ -86,7 +98,11 @@ void operator>>(const LexicalConverter &, PixelComponents &); void operator>>(const LexicalConverter &, PixelFormat &); PixelComponents components_from_graphics(Graphics::PixelFormat); -PixelFormat pixelformat_from_image(const Graphics::Image &); +PixelFormat pixelformat_from_image(const Graphics::Image &, bool = false); + +ComponentSwizzle get_required_swizzle(PixelComponents); +PixelComponents swizzle_components(PixelComponents, ComponentSwizzle); +PixelComponents unswizzle_components(PixelComponents, ComponentSwizzle); PixelFormat make_pixelformat(PixelComponents, DataType, bool = false); inline PixelComponents get_components(PixelFormat f) { return static_cast(f&0xFF); } @@ -99,10 +115,9 @@ inline unsigned get_pixel_size(PixelFormat f) { return get_component_count(f)*ge void require_pixelformat(PixelFormat); -GLenum get_gl_components(PixelComponents); -GLenum get_gl_pixelformat(PixelFormat); - } // namespace GL } // namespace Msp +#include "pixelformat_backend.h" + #endif