aboutsummaryrefslogtreecommitdiffstats
path: root/progs/tests/bug_3050.c
blob: a04e40eaf6efab754caf7aff735967203ed62d60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
 * (C) Copyright IBM Corporation 2006
 * 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 bug_3050.c
 *
 * Simple regression test for bug #3050.  Create a texture and make a few
 * calls to \c glGetTexLevelParameteriv.  If the bug still exists, trying
 * to get \c GL_TEXTURE_WITDH will cause a protocol error.
 * 
 * This test \b only applies to indirect-rendering.  This may mean that the
 * test needs to be run with the environment variable \c LIBGL_ALWAYS_INDIRECT
 * set to a non-zero value.
 *
 * \author Ian Romanick <idr@us.ibm.com>
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glew.h>
#include <GL/glut.h>

static int Width = 400;
static int Height = 200;
static const GLfloat Near = 5.0, Far = 25.0;


static void Display( void )
{
}


static void Reshape( int width, int height )
{
}


static void Key( unsigned char key, int x, int y )
{
   (void) x;
   (void) y;
   switch (key) {
      case 27:
         exit(0);
         break;
   }
   glutPostRedisplay();
}


static void Init( void )
{
   unsigned i;
   static const GLenum pnames[] = {
      GL_TEXTURE_RED_SIZE,
      GL_TEXTURE_GREEN_SIZE,
      GL_TEXTURE_BLUE_SIZE,
      GL_TEXTURE_ALPHA_SIZE,
      GL_TEXTURE_LUMINANCE_SIZE,
      GL_TEXTURE_INTENSITY_SIZE,
      GL_TEXTURE_BORDER,
      GL_TEXTURE_INTERNAL_FORMAT,
      GL_TEXTURE_WIDTH,
      GL_TEXTURE_HEIGHT,
      GL_TEXTURE_DEPTH,
      ~0
   };
   
       
   printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
   printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));

   printf("\nThis program should log some data about a texture and exit.\n");
   printf("This is a regression test for bug #3050.  If the bug still\n");
   printf("exists, a GLX protocol error will be generated.\n");
   printf("https://bugs.freedesktop.org/show_bug.cgi?id=3050\n\n");


   if ( ! glutExtensionSupported( "GL_NV_texture_rectangle" )
	&& ! glutExtensionSupported( "GL_EXT_texture_rectangle" )
	&& ! glutExtensionSupported( "GL_ARB_texture_rectangle" ) ) {
      printf( "This test requires one of GL_ARB_texture_rectangle, GL_EXT_texture_rectangle,\n"
	      "or GL_NV_texture_rectangle be supported\n." );
      exit( 1 );
   }
	

   glBindTexture( GL_TEXTURE_RECTANGLE_NV, 1 );
   glTexImage2D( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, 8, 8, 0,
		 GL_RGBA, GL_UNSIGNED_BYTE, NULL );

   for ( i = 0 ; pnames[i] != ~0 ; i++ ) {
      GLint param_i;
      GLfloat param_f;
      GLenum err;

      glGetTexLevelParameteriv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_i );
      err = glGetError();

      if ( err ) {
	 printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n"
		"error of 0x%04x!",
		pnames[i], err );
	 exit( 1 );
      }
      else {
	 printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = 0x%04x\n",
		pnames[i], param_i );
      }


      glGetTexLevelParameterfv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_f );
      err = glGetError();

      if ( err ) {
	 printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n"
		"error of 0x%04x!\n",
		pnames[i], err );
	 exit( 1 );
      }
      else {
	 printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = %.1f (0x%04x)\n",
		pnames[i], param_f, (GLint) param_f );
      }
   }
}


int main( int argc, char *argv[] )
{
   glutInit( &argc, argv );
   glutInitWindowPosition( 0, 0 );
   glutInitWindowSize( Width, Height );
   glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
   glutCreateWindow( "Bug #3050 Test" );
   glewInit();
   glutReshapeFunc( Reshape );
   glutKeyboardFunc( Key );
   glutDisplayFunc( Display );
   Init();
   return 0;
}