]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/pixelformat.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / core / pixelformat.h
index dde8594e723793a001c6166e575f18f8119aa86d..13bc03a8c059325d7272120f5a486b58e7e5d01e 100644 (file)
@@ -1,27 +1,17 @@
 #ifndef MSP_GL_PIXELFORMAT_H_
 #define MSP_GL_PIXELFORMAT_H_
 
-#include <msp/core/attributes.h>
 #include <msp/graphics/image.h>
 #include <msp/strings/lexicalcast.h>
-#include "gl.h"
-#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_bgra.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/gl/extensions/msp_luminance_formats.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
@@ -31,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
 {
@@ -48,8 +38,21 @@ 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,
+       RGBA_TO_RGB
+};
+
+/**
+Identifies a pixel format, with components and type.
+
+The values are bitfields laid as follows:
 
 tnfg ssss cccc cccc
 ││││    │         └╴Components (see PixelComponents)
@@ -60,10 +63,11 @@ 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
 {
+       NO_PIXELFORMAT = 0,
        R8 = 0x4100|RED,
        R16F = 0x3200|RED,
        R32F = 0x3400|RED,
@@ -95,7 +99,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<PixelComponents>(f&0xFF); }
@@ -108,10 +116,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