summaryrefslogtreecommitdiffstats
path: root/progs/tests
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2004-10-08 00:56:08 +0000
committerIan Romanick <idr@us.ibm.com>2004-10-08 00:56:08 +0000
commitaf0a4690db6d7f30ecc87b72d447856cd8c0a929 (patch)
tree73e8afcb807bfde8d0986caa8efc3907f07f64ac /progs/tests
parentcb1642a75cc5fd795d43d15f79118162d922f429 (diff)
downloadexternal_mesa3d-af0a4690db6d7f30ecc87b72d447856cd8c0a929.zip
external_mesa3d-af0a4690db6d7f30ecc87b72d447856cd8c0a929.tar.gz
external_mesa3d-af0a4690db6d7f30ecc87b72d447856cd8c0a929.tar.bz2
Add simple test program for Mesa bug #1028405.
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/Makefile1
-rw-r--r--progs/tests/no_s3tc.c97
2 files changed, 98 insertions, 0 deletions
diff --git a/progs/tests/Makefile b/progs/tests/Makefile
index 52b6b1e..a826762 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -31,6 +31,7 @@ SOURCES = antialias.c \
getprocaddress.c \
manytex.c \
multipal.c \
+ no_s3tc.c \
packedpixels.c \
pbo.c \
projtex.c \
diff --git a/progs/tests/no_s3tc.c b/progs/tests/no_s3tc.c
new file mode 100644
index 0000000..d3383ff
--- /dev/null
+++ b/progs/tests/no_s3tc.c
@@ -0,0 +1,97 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file no_s3tc.c
+ * Test program to verify the behavior of an OpenGL implementation when
+ * an application calls \c glCompressedTexImage2D with an unsupported (but
+ * valid) compression format. The most common example is calling it with
+ * \c GL_COMPRESSED_RGBA_S3TC_DXT1_EXT when GL_EXT_texture_compression_s3tc
+ * is not supported.
+ *
+ * This tests Mesa bug #1028405.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+
+static unsigned data[16];
+
+int
+main( int argc, char ** argv )
+{
+ float gl_version;
+ GLenum format;
+ GLuint size;
+ GLuint width;
+ GLenum err;
+
+
+ glutInit( & argc, argv );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
+
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 300, 300 );
+ glutCreateWindow( "No S3TC Test" );
+
+ gl_version = strtod( (const char *) glGetString( GL_VERSION ), NULL );
+ if ( ! glutExtensionSupported( "GL_ARB_texture_compression" )
+ && (gl_version < 1.3) ) {
+ fprintf( stderr, "Either OpenGL 1.3 or GL_ARB_texture_compression "
+ "must be supported.\n" );
+ return( EXIT_SUCCESS );
+ }
+
+
+ if ( ! glutExtensionSupported( "GL_EXT_texture_compression_s3tc" ) ) {
+ format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ width = 4;
+ size = 8;
+ }
+ else if ( ! glutExtensionSupported( "GL_3DFX_texture_compression_FXT1" ) ) {
+ format = GL_COMPRESSED_RGBA_FXT1_3DFX;
+ width = 8;
+ size = 16;
+ }
+ else {
+ fprintf( stderr, "Either GL_EXT_texture_compression_s3tc or "
+ "GL_3DFX_texture_compression_FXT1 must NOT be supported.\n" );
+ return( EXIT_SUCCESS );
+ }
+
+ glCompressedTexImage2D( GL_TEXTURE_2D, 0, format, width, 4, 0,
+ size, data );
+ err = glGetError();
+ if ( err != GL_INVALID_ENUM ) {
+ fprintf( stderr, "GL error 0x%04x should have been generated, but "
+ "0x%04x was generated instead.\n", GL_INVALID_ENUM, err );
+ }
+
+ return (err == GL_INVALID_ENUM) ? EXIT_SUCCESS : EXIT_FAILURE;
+}