4 * Tests whether the driver can support a full set of rectangle textures.
6 * (Prompted by a bug in R300 where the driver ran out of indirections).
9 #include "piglit-util.h"
11 int piglit_width
= 16 * 16, piglit_height
= 11 * 16;
12 int piglit_window_mode
= GLUT_DOUBLE
| GLUT_RGBA
| GLUT_ALPHA
;
14 static int NumTextures
= 16;
15 static GLuint Textures
[16];
17 static const GLubyte colors
[7][4] = {
27 static void ActiveTexture(int i
)
29 glActiveTexture(GL_TEXTURE0
+i
);
30 glClientActiveTexture(GL_TEXTURE0
+i
);
33 static void DoFrame(void)
37 glClearColor(0.5, 0.5, 0.0, 0.0);
38 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
42 for(i
= 0; i
< NumTextures
; ++i
)
43 glMultiTexCoord2f(GL_TEXTURE0
+i
, 0, 0);
45 for(i
= 0; i
< NumTextures
; ++i
)
46 glMultiTexCoord2f(GL_TEXTURE0
+i
, 16, 0);
48 for(i
= 0; i
< NumTextures
; ++i
)
49 glMultiTexCoord2f(GL_TEXTURE0
+i
, 16, 11);
51 for(i
= 0; i
< NumTextures
; ++i
)
52 glMultiTexCoord2f(GL_TEXTURE0
+i
, 0, 11);
59 static int DoTest(void)
64 glReadBuffer(GL_FRONT
);
67 for(x
= 0; x
< NumTextures
; ++x
) {
68 for(y
= 0; y
< 11; ++y
) {
74 glReadPixels((2*x
+1) * piglit_width
/ 32,
75 (2*y
+1) * piglit_height
/ 22,
76 1, 1, GL_RGBA
, GL_FLOAT
, probe
);
78 printf(" %i/%i: %f,%f,%f,%f", x
, y
,
79 probe
[0], probe
[1], probe
[2], probe
[3]);
82 for(i
= 0; i
< 4; ++i
) {
83 delta
[i
] = probe
[i
] - colors
[clr
][i
]/255.0;
85 if (delta
[i
] > dmax
) dmax
= delta
[i
];
86 else if (-delta
[i
] > dmax
) dmax
= -delta
[i
];
89 printf(" Delta: %f,%f,%f,%f\n", delta
[0], delta
[1], delta
[2], delta
[3]);
93 printf("Max delta: %f\n", dmax
);
110 return pass
? PIGLIT_SUCCESS
: PIGLIT_FAILURE
;
113 static void Reshape(int width
, int height
)
115 piglit_width
= width
;
116 piglit_height
= height
;
117 glViewport(0, 0, width
, height
);
118 glMatrixMode(GL_PROJECTION
);
120 glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
121 glScalef(1.0, 1.0, -1.0); // flip z-axis
122 glMatrixMode(GL_MODELVIEW
);
126 void piglit_init(int argc
, char **argv
)
131 if (!GLEW_VERSION_1_3
) {
132 printf("Requires OpenGL 1.3\n");
133 piglit_report_result(PIGLIT_SKIP
);
136 glutReshapeFunc(Reshape
);
138 piglit_require_extension("GL_ARB_texture_rectangle");
140 glGetIntegerv(GL_MAX_TEXTURE_UNITS
, &maxtextures
);
141 if (maxtextures
< NumTextures
)
142 NumTextures
= maxtextures
;
144 glGenTextures(NumTextures
, Textures
);
145 for(i
= 0; i
< NumTextures
; ++i
) {
146 GLubyte tex
[11*16*4];
151 glEnable(GL_TEXTURE_RECTANGLE_ARB
);
152 glBindTexture(GL_TEXTURE_RECTANGLE_ARB
, Textures
[i
]);
155 for(y
= 0; y
< 11; ++y
) {
156 for(x
= 0; x
< 16; ++x
, p
+= 4) {
158 p
[0] = p
[1] = p
[2] = p
[3] = 255;
161 p
[0] = colors
[clr
][0];
162 p
[1] = colors
[clr
][1];
163 p
[2] = colors
[clr
][2];
164 p
[3] = colors
[clr
][3];
169 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB
, 0, GL_RGBA
, 16, 11, 0,
170 GL_RGBA
, GL_UNSIGNED_BYTE
, tex
);
171 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
172 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
175 Reshape(piglit_width
, piglit_height
);