Test calling glTexSubImage2D mid-way through a frame.
[mesa.git] / progs / tests / no_s3tc.c
1 /*
2 * (C) Copyright IBM Corporation 2004
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /**
26 * \file no_s3tc.c
27 * Test program to verify the behavior of an OpenGL implementation when
28 * an application calls \c glCompressedTexImage2D with an unsupported (but
29 * valid) compression format. The most common example is calling it with
30 * \c GL_COMPRESSED_RGBA_S3TC_DXT1_EXT when GL_EXT_texture_compression_s3tc
31 * is not supported.
32 *
33 * This tests Mesa bug #1028405.
34 *
35 * \author Ian Romanick <idr@us.ibm.com>
36 */
37
38 #include <stdlib.h>
39 #include <stdio.h>
40 #include <string.h>
41 #include <GL/glut.h>
42 #include <GL/glext.h>
43
44 static unsigned data[16];
45
46 int
47 main( int argc, char ** argv )
48 {
49 float gl_version;
50 GLenum format;
51 GLuint size;
52 GLuint width;
53 GLenum err;
54
55
56 glutInit( & argc, argv );
57 glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
58
59 glutInitWindowPosition( 0, 0 );
60 glutInitWindowSize( 300, 300 );
61 glutCreateWindow( "No S3TC Test" );
62
63 gl_version = strtod( (const char *) glGetString( GL_VERSION ), NULL );
64 if ( ! glutExtensionSupported( "GL_ARB_texture_compression" )
65 && (gl_version < 1.3) ) {
66 fprintf( stderr, "Either OpenGL 1.3 or GL_ARB_texture_compression "
67 "must be supported.\n" );
68 return( EXIT_SUCCESS );
69 }
70
71
72 if ( ! glutExtensionSupported( "GL_EXT_texture_compression_s3tc" ) ) {
73 format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
74 width = 4;
75 size = 8;
76 }
77 else if ( ! glutExtensionSupported( "GL_3DFX_texture_compression_FXT1" ) ) {
78 format = GL_COMPRESSED_RGBA_FXT1_3DFX;
79 width = 8;
80 size = 16;
81 }
82 else {
83 fprintf( stderr, "Either GL_EXT_texture_compression_s3tc or "
84 "GL_3DFX_texture_compression_FXT1 must NOT be supported.\n" );
85 return( EXIT_SUCCESS );
86 }
87
88 glCompressedTexImage2D( GL_TEXTURE_2D, 0, format, width, 4, 0,
89 size, data );
90 err = glGetError();
91 if ( err != GL_INVALID_ENUM ) {
92 fprintf( stderr, "GL error 0x%04x should have been generated, but "
93 "0x%04x was generated instead.\n", GL_INVALID_ENUM, err );
94 }
95
96 return (err == GL_INVALID_ENUM) ? EXIT_SUCCESS : EXIT_FAILURE;
97 }