Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

no_s3tc.c 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. * \file no_s3tc.c
  26. * Test program to verify the behavior of an OpenGL implementation when
  27. * an application calls \c glCompressedTexImage2D with an unsupported (but
  28. * valid) compression format. The most common example is calling it with
  29. * \c GL_COMPRESSED_RGBA_S3TC_DXT1_EXT when GL_EXT_texture_compression_s3tc
  30. * is not supported.
  31. *
  32. * This tests Mesa bug #1028405.
  33. *
  34. * \author Ian Romanick <idr@us.ibm.com>
  35. */
  36. #include <stdlib.h>
  37. #include <stdio.h>
  38. #include <string.h>
  39. #include <GL/glew.h>
  40. #include <GL/glut.h>
  41. #include <GL/glext.h>
  42. static unsigned data[16];
  43. int
  44. main( int argc, char ** argv )
  45. {
  46. float gl_version;
  47. GLenum format;
  48. GLuint size;
  49. GLuint width;
  50. GLenum err;
  51. glutInit( & argc, argv );
  52. glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
  53. glutInitWindowPosition( 0, 0 );
  54. glutInitWindowSize( 300, 300 );
  55. glutCreateWindow( "No S3TC Test" );
  56. glewInit();
  57. gl_version = strtod( (const char *) glGetString( GL_VERSION ), NULL );
  58. if ( ! glutExtensionSupported( "GL_ARB_texture_compression" )
  59. && (gl_version < 1.3) ) {
  60. fprintf( stderr, "Either OpenGL 1.3 or GL_ARB_texture_compression "
  61. "must be supported.\n" );
  62. return( EXIT_SUCCESS );
  63. }
  64. if ( ! glutExtensionSupported( "GL_EXT_texture_compression_s3tc" ) ) {
  65. format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
  66. width = 4;
  67. size = 8;
  68. }
  69. else if ( ! glutExtensionSupported( "GL_3DFX_texture_compression_FXT1" ) ) {
  70. format = GL_COMPRESSED_RGBA_FXT1_3DFX;
  71. width = 8;
  72. size = 16;
  73. }
  74. else {
  75. fprintf( stderr, "Either GL_EXT_texture_compression_s3tc or "
  76. "GL_3DFX_texture_compression_FXT1 must NOT be supported.\n" );
  77. return( EXIT_SUCCESS );
  78. }
  79. glCompressedTexImage2D( GL_TEXTURE_2D, 0, format, width, 4, 0,
  80. size, data );
  81. err = glGetError();
  82. if ( err != GL_INVALID_ENUM ) {
  83. fprintf( stderr, "GL error 0x%04x should have been generated, but "
  84. "0x%04x was generated instead.\n", GL_INVALID_ENUM, err );
  85. }
  86. return (err == GL_INVALID_ENUM) ? EXIT_SUCCESS : EXIT_FAILURE;
  87. }