2 * Copyright (c) The Piglit project 2008
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * Test whether 1D textures correctly ignore the T coordinate wrap mode.
28 * Since 1D textures are genuine one-dimensional objects, the T coordinate
29 * shouldn't affect them at all. However, R300 simulates them as flat
30 * 2D textures, which caused incorrect sampling of border colors.
33 #include "piglit-util.h"
34 #include "piglit-framework.h"
36 int piglit_width
= 256, piglit_height
= 128;
37 int piglit_window_mode
= GLUT_RGB
| GLUT_DOUBLE
;
39 static const GLfloat TextureColor
[3] = { 1.0, 0.5, 0.0 };
42 static GLboolean
test(GLenum wrapt
, int cellx
, int celly
)
47 glTranslatef(cellx
*0.25, celly
*0.5, 0.0);
48 glScalef(0.25, 0.5, 1.0);
49 glTexParameteri(GL_TEXTURE_1D
, GL_TEXTURE_WRAP_T
, wrapt
);
51 glTexCoord2f(0, 0); glVertex2f(0, 0);
52 glTexCoord2f(1, 0); glVertex2f(1, 0);
53 glTexCoord2f(1, 1); glVertex2f(1, 1);
54 glTexCoord2f(0, 1); glVertex2f(0, 1);
58 glReadBuffer(GL_BACK
);
60 /* Take more than one sample, just to be sure */
61 for(sy
= 0; sy
< 4; ++sy
) {
62 for(sx
= 0; sx
< 4; ++sx
) {
63 int x
= (cellx
*5 + sx
+ 1)*piglit_width
/20;
64 int y
= (celly
*5 + sy
+ 1)*piglit_height
/10;
66 if (!piglit_probe_pixel_rgb(x
, y
, TextureColor
)) {
67 fprintf(stderr
, "Fail in cell %i,%i (texwrap = 0x%x)\n", cellx
, celly
, wrapt
);
80 GLboolean pass
= GL_TRUE
;
82 glClearColor(0.5, 0.5, 0.5, 1.0);
83 glClear(GL_COLOR_BUFFER_BIT
);
85 /* Draw eight tiles, each with a different tex wrap mode.
86 * They should all look the same.
88 pass
&= test(GL_REPEAT
, 0, 0);
89 pass
&= test(GL_CLAMP
, 1, 0);
90 pass
&= test(GL_CLAMP_TO_EDGE
, 2, 0);
91 pass
&= test(GL_CLAMP_TO_BORDER
, 3, 0);
92 pass
&= test(GL_MIRRORED_REPEAT
, 0, 1);
93 if (glutExtensionSupported("GL_EXT_texture_mirror_clamp")) {
94 pass
&= test(GL_MIRROR_CLAMP_EXT
, 1, 1);
95 pass
&= test(GL_MIRROR_CLAMP_TO_EDGE_EXT
, 2, 1);
96 pass
&= test(GL_MIRROR_CLAMP_TO_BORDER_EXT
, 3, 1);
101 return pass
? PIGLIT_SUCCESS
: PIGLIT_FAILURE
;
104 void piglit_init(int argc
, char **argv
)
109 glTexParameteri(GL_TEXTURE_1D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
110 glTexParameteri(GL_TEXTURE_1D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
111 glTexParameteri(GL_TEXTURE_1D
, GL_TEXTURE_WRAP_S
, GL_REPEAT
);
112 glTexImage1D(GL_TEXTURE_1D
, 0, GL_RGB
, 1, 0, GL_RGB
, GL_FLOAT
, TextureColor
);
113 glEnable(GL_TEXTURE_1D
);
115 piglit_ortho_projection(1.0, 1.0, GL_FALSE
);
117 if (!piglit_automatic
)
118 printf("You should see a flat orange color\n");