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.

bug_3050.c 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * (C) Copyright IBM Corporation 2006
  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 bug_3050.c
  26. *
  27. * Simple regression test for bug #3050. Create a texture and make a few
  28. * calls to \c glGetTexLevelParameteriv. If the bug still exists, trying
  29. * to get \c GL_TEXTURE_WITDH will cause a protocol error.
  30. *
  31. * This test \b only applies to indirect-rendering. This may mean that the
  32. * test needs to be run with the environment variable \c LIBGL_ALWAYS_INDIRECT
  33. * set to a non-zero value.
  34. *
  35. * \author Ian Romanick <idr@us.ibm.com>
  36. */
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include <GL/glut.h>
  41. static int Width = 400;
  42. static int Height = 200;
  43. static const GLfloat Near = 5.0, Far = 25.0;
  44. static void Display( void )
  45. {
  46. }
  47. static void Reshape( int width, int height )
  48. {
  49. }
  50. static void Key( unsigned char key, int x, int y )
  51. {
  52. (void) x;
  53. (void) y;
  54. switch (key) {
  55. case 27:
  56. exit(0);
  57. break;
  58. }
  59. glutPostRedisplay();
  60. }
  61. static void Init( void )
  62. {
  63. unsigned i;
  64. static const GLenum pnames[] = {
  65. GL_TEXTURE_RED_SIZE,
  66. GL_TEXTURE_GREEN_SIZE,
  67. GL_TEXTURE_BLUE_SIZE,
  68. GL_TEXTURE_ALPHA_SIZE,
  69. GL_TEXTURE_LUMINANCE_SIZE,
  70. GL_TEXTURE_INTENSITY_SIZE,
  71. GL_TEXTURE_BORDER,
  72. GL_TEXTURE_INTERNAL_FORMAT,
  73. GL_TEXTURE_WIDTH,
  74. GL_TEXTURE_HEIGHT,
  75. GL_TEXTURE_DEPTH,
  76. ~0
  77. };
  78. printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
  79. printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
  80. printf("\nThis program should log some data about a texture and exit.\n");
  81. printf("This is a regression test for bug #3050. If the bug still\n");
  82. printf("exists, a GLX protocol error will be generated.\n");
  83. printf("https://bugs.freedesktop.org/show_bug.cgi?id=3050\n\n");
  84. if ( ! glutExtensionSupported( "GL_NV_texture_rectangle" )
  85. && ! glutExtensionSupported( "GL_EXT_texture_rectangle" )
  86. && ! glutExtensionSupported( "GL_ARB_texture_rectangle" ) ) {
  87. printf( "This test requires one of GL_ARB_texture_rectangle, GL_EXT_texture_rectangle,\n"
  88. "or GL_NV_texture_rectangle be supported\n." );
  89. exit( 1 );
  90. }
  91. glBindTexture( GL_TEXTURE_RECTANGLE_NV, 1 );
  92. glTexImage2D( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, 8, 8, 0,
  93. GL_RGBA, GL_UNSIGNED_BYTE, NULL );
  94. for ( i = 0 ; pnames[i] != ~0 ; i++ ) {
  95. GLint param_i;
  96. GLfloat param_f;
  97. GLenum err;
  98. glGetTexLevelParameteriv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_i );
  99. err = glGetError();
  100. if ( err ) {
  101. printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n"
  102. "error of 0x%04x!",
  103. pnames[i], err );
  104. exit( 1 );
  105. }
  106. else {
  107. printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = 0x%04x\n",
  108. pnames[i], param_i );
  109. }
  110. glGetTexLevelParameterfv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_f );
  111. err = glGetError();
  112. if ( err ) {
  113. printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n"
  114. "error of 0x%04x!\n",
  115. pnames[i], err );
  116. exit( 1 );
  117. }
  118. else {
  119. printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = %.1f (0x%04x)\n",
  120. pnames[i], param_f, (GLint) param_f );
  121. }
  122. }
  123. }
  124. int main( int argc, char *argv[] )
  125. {
  126. glutInit( &argc, argv );
  127. glutInitWindowPosition( 0, 0 );
  128. glutInitWindowSize( Width, Height );
  129. glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
  130. glutCreateWindow( "Bug #3050 Test" );
  131. glutReshapeFunc( Reshape );
  132. glutKeyboardFunc( Key );
  133. glutDisplayFunc( Display );
  134. Init();
  135. return 0;
  136. }