all formats or just those without restrictions/limitations should be returned.
We want all when validating the internalFormat parameter to
glCompressedTexImage2D but only want unrestricted formats when handling the
GL_COMPRESSED_TEXTURE_FORMATS query.
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetBooleanv");
- params[0] = INT_TO_BOOLEAN(_mesa_get_compressed_formats(ctx, NULL));
+ params[0] = INT_TO_BOOLEAN(_mesa_get_compressed_formats(ctx, NULL, GL_FALSE));
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetBooleanv");
{
GLint formats[100];
- GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
ASSERT(n <= 100);
for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]);
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetFloatv");
- params[0] = (GLfloat)(_mesa_get_compressed_formats(ctx, NULL));
+ params[0] = (GLfloat)(_mesa_get_compressed_formats(ctx, NULL, GL_FALSE));
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetFloatv");
{
GLint formats[100];
- GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
ASSERT(n <= 100);
for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]);
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetIntegerv");
- params[0] = _mesa_get_compressed_formats(ctx, NULL);
+ params[0] = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE);
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetIntegerv");
{
GLint formats[100];
- GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
ASSERT(n <= 100);
for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]);
( "GL_TEXTURE_COMPRESSION_HINT_ARB", GLint,
["ctx->Hint.TextureCompression"], "", ["ARB_texture_compression"] ),
( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint,
- ["_mesa_get_compressed_formats(ctx, NULL)"], "", ["ARB_texture_compression"] ),
+ ["_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)"],
+ "", ["ARB_texture_compression"] ),
( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum,
[],
"""GLint formats[100];
- GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
ASSERT(n <= 100);
for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]);""",
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.5.1
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "texformat.h"
#include "texstore.h"
+
/**
- * Get the list of supported internal compression formats.
+ * Return list of (and count of) all specific texture compression
+ * formats that are supported.
*
- * \param ctx GL context.
- * \param formats the resulting format list (may be NULL).
+ * \param ctx the GL context
+ * \param formats the resulting format list (may be NULL).
+ * \param all if true return all formats, even those with some kind
+ * of restrictions/limitations (See GL_ARB_texture_compression
+ * spec for more info).
*
* \return number of formats.
*/
GLuint
-_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats )
+_mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all)
{
GLuint n = 0;
if (ctx->Extensions.ARB_texture_compression) {
if (ctx->Extensions.EXT_texture_compression_s3tc) {
if (formats) {
formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
- /* Skip this one because it has a restriction (all transparent
- * pixels become black). See the texture compressions spec for
- * a detailed explanation. This is what NVIDIA does.
- formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- */
+ /* This format has some restrictions/limitations and so should
+ * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query.
+ * Specifically, all transparent pixels become black. NVIDIA
+ * omits this format too.
+ */
+ if (all)
+ formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
}
else {
n += 3;
+ if (all)
+ n += 1;
}
}
if (ctx->Extensions.S3_s3tc) {
#if _HAVE_FULL_GL
extern GLuint
-_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats );
+_mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all);
extern GLuint
_mesa_compressed_texture_size( GLcontext *ctx,
GLint supported[100]; /* 100 should be plenty */
GLuint i, n;
- n = _mesa_get_compressed_formats(ctx, supported);
+ n = _mesa_get_compressed_formats(ctx, supported, GL_TRUE);
ASSERT(n < 100);
for (i = 0; i < n; i++) {
if ((GLint) internalFormat == supported[i]) {