2 * Copyright © Marek Olšák <maraeo@gmail.com>
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 shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #include "piglit-util-gl.h"
24 PIGLIT_GL_TEST_CONFIG_BEGIN
26 config
.supports_gl_compat_version
= 10;
28 config
.window_width
= 200;
29 config
.window_height
= 40;
30 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
32 PIGLIT_GL_TEST_CONFIG_END
34 static const float colors
[6][3] = {
43 static const GLenum targets
[6] = {
44 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
,
45 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
,
46 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
,
47 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
,
48 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
,
49 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
52 static void draw_quad(int x
, int y
, float s
, float t
, float r
)
55 glTexCoord3f(s
, t
, r
);
58 glVertex2i(x
+20, y
+20);
63 enum piglit_result
piglit_display(void)
65 GLboolean pass
= GL_TRUE
;
66 const float violet
[3] = {0.5, 0, 0.5};
68 glClear(GL_COLOR_BUFFER_BIT
);
70 draw_quad(10, 10, 0.99, 0, 1);
71 draw_quad(40, 10, 1, 0, 0.99);
73 glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS
);
74 draw_quad(70, 10, 0.99, 0, 1);
75 draw_quad(100, 10, 1, 0, 0.99);
76 glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS
);
78 pass
= piglit_probe_pixel_rgb(20, 20, colors
[4]) && pass
;
79 pass
= piglit_probe_pixel_rgb(50, 20, colors
[0]) && pass
;
80 pass
= piglit_probe_pixel_rgb(80, 20, violet
) && pass
;
81 pass
= piglit_probe_pixel_rgb(110, 20, violet
) && pass
;
83 piglit_present_results();
85 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
88 void piglit_init(int argc
, char **argv
)
92 piglit_require_extension("GL_ARB_texture_cube_map");
93 piglit_require_extension("GL_ARB_seamless_cube_map");
95 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB
, 1);
96 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
);
97 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
);
98 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB
, GL_TEXTURE_WRAP_R
, GL_CLAMP_TO_EDGE
);
99 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
100 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
102 for (i
= 0; i
< 6; i
++) {
103 glTexImage2D(targets
[i
], 0, GL_RGBA8
, 1, 1, 0, GL_RGB
, GL_FLOAT
, colors
[i
]);
106 glEnable(GL_TEXTURE_CUBE_MAP_ARB
);
108 glClearColor(.3, .3, .3, 0);
109 glColor3f( 1.0, 1.0, 1.0 );
111 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);