demos: add missing binaries to .gitignore
[mesa-demos.git] / src / tests / bug_3050.c
blob51dd27548ae382463c5172feb5d3410c57f439b3
1 /*
2 * (C) Copyright IBM Corporation 2006
3 * All Rights Reserved.
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:
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.
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.
25 /**
26 * \file bug_3050.c
28 * Simple regression test for bug #3050. Create a texture and make a few
29 * calls to \c glGetTexLevelParameteriv. If the bug still exists, trying
30 * to get \c GL_TEXTURE_WITDH will cause a protocol error.
32 * This test \b only applies to indirect-rendering. This may mean that the
33 * test needs to be run with the environment variable \c LIBGL_ALWAYS_INDIRECT
34 * set to a non-zero value.
36 * \author Ian Romanick <idr@us.ibm.com>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <GL/glew.h>
43 #include "glut_wrap.h"
45 static int Width = 400;
46 static int Height = 200;
47 static const GLfloat Near = 5.0, Far = 25.0;
50 static void Display( void )
55 static void Reshape( int width, int height )
60 static void Key( unsigned char key, int x, int y )
62 (void) x;
63 (void) y;
64 switch (key) {
65 case 27:
66 exit(0);
67 break;
69 glutPostRedisplay();
73 static void Init( void )
75 unsigned i;
76 static const GLenum pnames[] = {
77 GL_TEXTURE_RED_SIZE,
78 GL_TEXTURE_GREEN_SIZE,
79 GL_TEXTURE_BLUE_SIZE,
80 GL_TEXTURE_ALPHA_SIZE,
81 GL_TEXTURE_LUMINANCE_SIZE,
82 GL_TEXTURE_INTENSITY_SIZE,
83 GL_TEXTURE_BORDER,
84 GL_TEXTURE_INTERNAL_FORMAT,
85 GL_TEXTURE_WIDTH,
86 GL_TEXTURE_HEIGHT,
87 GL_TEXTURE_DEPTH,
92 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
93 printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
95 printf("\nThis program should log some data about a texture and exit.\n");
96 printf("This is a regression test for bug #3050. If the bug still\n");
97 printf("exists, a GLX protocol error will be generated.\n");
98 printf("https://bugs.freedesktop.org/show_bug.cgi?id=3050\n\n");
101 if ( ! glutExtensionSupported( "GL_NV_texture_rectangle" )
102 && ! glutExtensionSupported( "GL_EXT_texture_rectangle" )
103 && ! glutExtensionSupported( "GL_ARB_texture_rectangle" ) ) {
104 printf( "This test requires one of GL_ARB_texture_rectangle, GL_EXT_texture_rectangle,\n"
105 "or GL_NV_texture_rectangle be supported\n." );
106 exit( 1 );
110 glBindTexture( GL_TEXTURE_RECTANGLE_NV, 1 );
111 glTexImage2D( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, 8, 8, 0,
112 GL_RGBA, GL_UNSIGNED_BYTE, NULL );
114 for ( i = 0 ; pnames[i] != ~0 ; i++ ) {
115 GLint param_i;
116 GLfloat param_f;
117 GLenum err;
119 glGetTexLevelParameteriv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_i );
120 err = glGetError();
122 if ( err ) {
123 printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n"
124 "error of 0x%04x!",
125 pnames[i], err );
126 exit( 1 );
128 else {
129 printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = 0x%04x\n",
130 pnames[i], param_i );
134 glGetTexLevelParameterfv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_f );
135 err = glGetError();
137 if ( err ) {
138 printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n"
139 "error of 0x%04x!\n",
140 pnames[i], err );
141 exit( 1 );
143 else {
144 printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = %.1f (0x%04x)\n",
145 pnames[i], param_f, (GLint) param_f );
151 int main( int argc, char *argv[] )
153 glutInit( &argc, argv );
154 glutInitWindowPosition( 0, 0 );
155 glutInitWindowSize( Width, Height );
156 glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
157 glutCreateWindow( "Bug #3050 Test" );
158 glewInit();
159 glutReshapeFunc( Reshape );
160 glutKeyboardFunc( Key );
161 glutDisplayFunc( Display );
162 Init();
163 return 0;