mesa: added _mesa_get_format_bits()
authorBrian Paul <brianp@vmware.com>
Mon, 28 Sep 2009 01:07:44 +0000 (19:07 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 28 Sep 2009 01:07:44 +0000 (19:07 -0600)
src/mesa/main/formats.c
src/mesa/main/formats.h

index 5c2bf5ece3e61748442763b33807fb7b369c0862..62a2d70744d6f07e27234e3039a7d5a1dd771396 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 
+#include "imports.h"
 #include "formats.h"
 #include "config.h"
 #include "texstore.h"
@@ -785,3 +786,33 @@ _mesa_format_to_type_and_comps2(gl_format format,
    }
 }
 
+
+GLint
+_mesa_get_format_bits(gl_format format, GLenum pname)
+{
+   const struct gl_format_info *info = _mesa_get_format_info(format);
+
+   switch (pname) {
+   case GL_TEXTURE_RED_SIZE:
+      return info->RedBits;
+   case GL_TEXTURE_GREEN_SIZE:
+      return info->GreenBits;
+   case GL_TEXTURE_BLUE_SIZE:
+      return info->BlueBits;
+   case GL_TEXTURE_ALPHA_SIZE:
+      return info->AlphaBits;
+   case GL_TEXTURE_INTENSITY_SIZE:
+      return info->IntensityBits;
+   case GL_TEXTURE_LUMINANCE_SIZE:
+      return info->LuminanceBits;
+   case GL_TEXTURE_INDEX_SIZE_EXT:
+      return info->IndexBits;
+   case GL_TEXTURE_DEPTH_SIZE_ARB:
+      return info->DepthBits;
+   case GL_TEXTURE_STENCIL_SIZE_EXT:
+      return info->StencilBits;
+   default:
+      _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()");
+      return 0;
+   }
+}
index e79991ad41009ae9c61504c4afe1b48b16ebe5bb..441cf3eac6d25f59ac2d929d1900d8d97924051e 100644 (file)
@@ -208,6 +208,10 @@ extern void
 _mesa_format_to_type_and_comps2(gl_format format,
                                 GLenum *datatype, GLuint *comps);
 
+extern GLint
+_mesa_get_format_bits(gl_format format, GLenum pname);
+
+
 extern void
 _mesa_test_formats(void);