2 * Copyright © 2011 Intel Corporation
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * 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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * Test that glCopyTexImage() into a texture with a texture border
26 * gets correct non-border texels.
30 #include "piglit-util-gl.h"
32 /* Size of the body of the texture, not counting border. */
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config
.supports_gl_compat_version
= 10;
39 config
.window_width
= TEX_SIZE
*2+30;
40 config
.window_height
= TEX_SIZE
+20;
41 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
42 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
44 PIGLIT_GL_TEST_CONFIG_END
50 int quad_w
= TEX_SIZE
/ 2;
51 int quad_h
= TEX_SIZE
/ 2;
52 float red
[] = {1.0, 0.0, 0.0, 0.0};
53 float green
[] = {0.0, 1.0, 0.0, 0.0};
54 float blue
[] = {0.0, 0.0, 1.0, 0.0};
55 float white
[] = {1.0, 1.0, 1.0, 0.0};
59 piglit_ortho_projection(piglit_width
, piglit_height
, false);
61 glClearColor(0.5, 0.5, 0.5, 0.5);
62 glClear(GL_COLOR_BUFFER_BIT
);
68 piglit_draw_rect(x
, y
, quad_w
, quad_h
);
70 piglit_draw_rect(x
+ quad_w
, y
, quad_w
, quad_h
);
72 piglit_draw_rect(x
, y
+ quad_h
, quad_w
, quad_h
);
74 piglit_draw_rect(x
+ quad_w
, y
+ quad_h
, quad_w
, quad_h
);
76 glGenTextures(1, &tex
);
77 glBindTexture(GL_TEXTURE_2D
, tex
);
78 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
79 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
81 /* Copy the rectangle drawn to our texture, with a 1-pixel
84 glCopyTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
,
86 TEX_SIZE
+ 2, TEX_SIZE
+ 2,
92 glEnable(GL_TEXTURE_2D
);
93 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_REPLACE
);
94 piglit_draw_rect_tex(x
, y
, TEX_SIZE
, TEX_SIZE
,
96 glDisable(GL_TEXTURE_2D
);
97 glDeleteTextures(1, &tex
);
99 pass
= piglit_probe_rect_rgba(x
, y
,
100 quad_w
, quad_h
, red
) && pass
;
101 pass
= piglit_probe_rect_rgba(x
+ quad_w
, y
,
102 quad_w
, quad_h
, green
) && pass
;
103 pass
= piglit_probe_rect_rgba(x
, y
+ quad_h
,
104 quad_w
, quad_h
, blue
) && pass
;
105 pass
= piglit_probe_rect_rgba(x
+ quad_w
, y
+ quad_h
,
106 quad_w
, quad_h
, white
) && pass
;
108 piglit_present_results();
110 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
114 piglit_init(int argc
, char **argv
)