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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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/glew.h>
  41. #include <GL/glut.h>
  42. static int Width = 400;
  43. static int Height = 200;
  44. static const GLfloat Near = 5.0, Far = 25.0;
  45. static void Display( void )
  46. {
  47. }
  48. static void Reshape( int width, int height )
  49. {
  50. }
  51. static void Key( unsigned char key, int x, int y )
  52. {
  53. (void) x;
  54. (void) y;
  55. switch (key) {
  56. case 27:
  57. exit(0);
  58. break;
  59. }
  60. glutPostRedisplay();
  61. }
  62. static void Init( void )
  63. {
  64. unsigned i;
  65. static const GLenum pnames[] = {
  66. GL_TEXTURE_RED_SIZE,
  67. GL_TEXTURE_GREEN_SIZE,
  68. GL_TEXTURE_BLUE_SIZE,
  69. GL_TEXTURE_ALPHA_SIZE,
  70. GL_TEXTURE_LUMINANCE_SIZE,
  71. GL_TEXTURE_INTENSITY_SIZE,
  72. GL_TEXTURE_BORDER,
  73. GL_TEXTURE_INTERNAL_FORMAT,
  74. GL_TEXTURE_WIDTH,
  75. GL_TEXTURE_HEIGHT,
  76. GL_TEXTURE_DEPTH,
  77. ~0
  78. };
  79. printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
  80. printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
  81. printf("\nThis program should log some data about a texture and exit.\n");
  82. printf("This is a regression test for bug #3050. If the bug still\n");
  83. printf("exists, a GLX protocol error will be generated.\n");
  84. printf("https://bugs.freedesktop.org/show_bug.cgi?id=3050\n\n");
  85. if ( ! glutExtensionSupported( "GL_NV_texture_rectangle" )
  86. && ! glutExtensionSupported( "GL_EXT_texture_rectangle" )
  87. && ! glutExtensionSupported( "GL_ARB_texture_rectangle" ) ) {
  88. printf( "This test requires one of GL_ARB_texture_rectangle, GL_EXT_texture_rectangle,\n"
  89. "or GL_NV_texture_rectangle be supported\n." );
  90. exit( 1 );
  91. }
  92. glBindTexture( GL_TEXTURE_RECTANGLE_NV, 1 );
  93. glTexImage2D( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, 8, 8, 0,
  94. GL_RGBA, GL_UNSIGNED_BYTE, NULL );
  95. for ( i = 0 ; pnames[i] != ~0 ; i++ ) {
  96. GLint param_i;
  97. GLfloat param_f;
  98. GLenum err;
  99. glGetTexLevelParameteriv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_i );
  100. err = glGetError();
  101. if ( err ) {
  102. printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n"
  103. "error of 0x%04x!",
  104. pnames[i], err );
  105. exit( 1 );
  106. }
  107. else {
  108. printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = 0x%04x\n",
  109. pnames[i], param_i );
  110. }
  111. glGetTexLevelParameterfv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_f );
  112. err = glGetError();
  113. if ( err ) {
  114. printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n"
  115. "error of 0x%04x!\n",
  116. pnames[i], err );
  117. exit( 1 );
  118. }
  119. else {
  120. printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = %.1f (0x%04x)\n",
  121. pnames[i], param_f, (GLint) param_f );
  122. }
  123. }
  124. }
  125. int main( int argc, char *argv[] )
  126. {
  127. glutInit( &argc, argv );
  128. glutInitWindowPosition( 0, 0 );
  129. glutInitWindowSize( Width, Height );
  130. glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
  131. glutCreateWindow( "Bug #3050 Test" );
  132. glewInit();
  133. glutReshapeFunc( Reshape );
  134. glutKeyboardFunc( Key );
  135. glutDisplayFunc( Display );
  136. Init();
  137. return 0;
  138. }