1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/*
* Copyright © Marek Olšák <maraeo@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "piglit-util-gl-common.h"
PIGLIT_GL_TEST_MAIN(
200 /*window_width*/,
40 /*window_height*/,
GLUT_RGB | GLUT_DOUBLE)
static const float colors[6][3] = {
{1, 0, 0},
{0, 1, 1},
{0, 1, 0},
{1, 0, 1},
{0, 0, 1},
{1, 1, 0}
};
static const GLenum targets[6] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
};
static void draw_quad(int x, int y, float s, float t, float r)
{
glBegin(GL_QUADS);
glTexCoord3f(s, t, r);
glVertex2i(x, y);
glVertex2i(x, y+20);
glVertex2i(x+20, y+20);
glVertex2i(x+20, y);
glEnd();
}
enum piglit_result piglit_display(void)
{
GLboolean pass = GL_TRUE;
const float violet[3] = {0.5, 0, 0.5};
glClear(GL_COLOR_BUFFER_BIT);
draw_quad(10, 10, 0.99, 0, 1);
draw_quad(40, 10, 1, 0, 0.99);
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
draw_quad(70, 10, 0.99, 0, 1);
draw_quad(100, 10, 1, 0, 0.99);
glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
glutSwapBuffers();
pass = piglit_probe_pixel_rgb(20, 20, colors[4]) && pass;
pass = piglit_probe_pixel_rgb(50, 20, colors[0]) && pass;
pass = piglit_probe_pixel_rgb(80, 20, violet) && pass;
pass = piglit_probe_pixel_rgb(110, 20, violet) && pass;
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
void piglit_init(int argc, char **argv)
{
GLint i;
piglit_require_extension("GL_ARB_texture_cube_map");
piglit_require_extension("GL_ARB_seamless_cube_map");
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 1);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
for (i = 0; i < 6; i++) {
glTexImage2D(targets[i], 0, GL_RGBA8, 1, 1, 0, GL_RGB, GL_FLOAT, colors[i]);
}
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glClearColor(.3, .3, .3, 0);
glColor3f( 1.0, 1.0, 1.0 );
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
}
|