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-gl.h"
11 PIGLIT_GL_TEST_CONFIG_BEGIN
13 config
.supports_gl_compat_version
= 10;
15 config
.window_width
= 16*16;
16 config
.window_height
= 11*16;
17 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
18 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
20 PIGLIT_GL_TEST_CONFIG_END
22 static int NumTextures
= 16;
23 static GLuint Textures
[16];
25 static const GLubyte colors
[7][4] = {
35 static void ActiveTexture(int i
)
37 glActiveTexture(GL_TEXTURE0
+i
);
38 glClientActiveTexture(GL_TEXTURE0
+i
);
41 static void DoFrame(void)
45 glClearColor(0.5, 0.5, 0.0, 0.0);
46 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
50 for(i
= 0; i
< NumTextures
; ++i
)
51 glMultiTexCoord2f(GL_TEXTURE0
+i
, 0, 0);
53 for(i
= 0; i
< NumTextures
; ++i
)
54 glMultiTexCoord2f(GL_TEXTURE0
+i
, 16, 0);
56 for(i
= 0; i
< NumTextures
; ++i
)
57 glMultiTexCoord2f(GL_TEXTURE0
+i
, 16, 11);
59 for(i
= 0; i
< NumTextures
; ++i
)
60 glMultiTexCoord2f(GL_TEXTURE0
+i
, 0, 11);
71 for(x
= 0; x
< NumTextures
; ++x
) {
72 for(y
= 0; y
< 11; ++y
) {
75 int probe_x
= (2*x
+1) * piglit_width
/ 32;
76 int probe_y
= (2*y
+1) * piglit_height
/ 22;
80 expected
[0] = colors
[clr
][0] / 255.0;
81 expected
[1] = colors
[clr
][1] / 255.0;
82 expected
[2] = colors
[clr
][2] / 255.0;
83 expected
[3] = colors
[clr
][3] / 255.0;
85 pass
= pass
&& piglit_probe_pixel_rgba(probe_x
, probe_y
,
102 piglit_present_results();
104 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
107 void piglit_init(int argc
, char **argv
)
112 piglit_require_gl_version(13);
114 piglit_require_extension("GL_ARB_texture_rectangle");
116 glGetIntegerv(GL_MAX_TEXTURE_UNITS
, &maxtextures
);
117 if (maxtextures
< NumTextures
)
118 NumTextures
= maxtextures
;
120 glGenTextures(NumTextures
, Textures
);
121 for(i
= 0; i
< NumTextures
; ++i
) {
122 GLubyte tex
[11*16*4];
127 glEnable(GL_TEXTURE_RECTANGLE_ARB
);
128 glBindTexture(GL_TEXTURE_RECTANGLE_ARB
, Textures
[i
]);
131 for(y
= 0; y
< 11; ++y
) {
132 for(x
= 0; x
< 16; ++x
, p
+= 4) {
134 p
[0] = p
[1] = p
[2] = p
[3] = 255;
137 p
[0] = colors
[clr
][0];
138 p
[1] = colors
[clr
][1];
139 p
[2] = colors
[clr
][2];
140 p
[3] = colors
[clr
][3];
145 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB
, 0, GL_RGBA
, 16, 11, 0,
146 GL_RGBA
, GL_UNSIGNED_BYTE
, tex
);
147 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
148 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
151 piglit_ortho_projection(1.0, 1.0, GL_FALSE
);