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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/*
* Copyright © 2011 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 (including the next
* paragraph) 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
* THE AUTHORS OR COPYRIGHT HOLDERS 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.h"
PIGLIT_GL_TEST_MAIN(
100 /*window_width*/,
130 /*window_height*/,
GLUT_RGB | GLUT_DOUBLE)
void
piglit_init(int argc, char **argv)
{
if (piglit_get_gl_version() < 14) {
printf("Requires OpenGL 1.4.\n");
piglit_report_result(PIGLIT_SKIP);
}
}
static void rotate_colors(float *array)
{
unsigned i;
float tmp[3];
for (i = 0; i < 3; i++) {
memcpy(tmp, array + i*5 + 2, 12);
memcpy(array + i*5 + 2, array + i*5 + 17, 12);
memcpy(array + i*5 + 17, array + i*5 + 32, 12);
memcpy(array + i*5 + 32, array + i*5 + 47, 12);
memcpy(array + i*5 + 47, tmp, 12);
}
}
enum piglit_result
piglit_display(void)
{
GLboolean pass = GL_TRUE;
float array[] = {
10, 10, 1, 0, 0,
27, 10, 1, 0, 0,
10, 30, 1, 0, 0,
30, 10, 0, 1, 0,
47, 10, 0, 1, 0,
30, 30, 0, 1, 0,
50, 10, 0, 0, 1,
67, 10, 0, 0, 1,
50, 30, 0, 0, 1,
70, 10, 1, 0, 1,
87, 10, 1, 0, 1,
70, 30, 1, 0, 1
};
float seccol[] = {
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
0.2, 0.2, 0.2,
};
float c0[] = {1, 0.2, 0.2};
float c1[] = {0.2, 1, 0.2};
float c2[] = {0.2, 0.2, 1};
float c3[] = {1, 0.2, 1};
short indices[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};
int i, j;
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
printf("From bottom to top:\n");
glEnable(GL_COLOR_SUM);
glLoadIdentity();
/* State change: Vertex arrays. */
glVertexPointer(2, GL_FLOAT, 20, array);
glColorPointer(3, GL_FLOAT, 20, array + 2);
glSecondaryColorPointer(3, GL_FLOAT, 0, seccol);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
/* The vertex array state should be preserved after glClear. */
glClear(GL_COLOR_BUFFER_BIT);
/* Draw. */
printf("DrawElements\n");
for (i = 0; i < 4; i++)
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, indices + i*3);
/* State change: Constant buffer. */
glTranslatef(0, 30, 0);
rotate_colors(array);
/* Draw. */
printf("DrawArrays\n");
for (i = 0; i < 4; i++)
glDrawArrays(GL_TRIANGLES, i*3, 3);
/* State change: Vertex arrays. */
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
/* State change: Constant buffer. */
glTranslatef(0, 30, 0);
rotate_colors(array);
/* Draw. */
printf("Begin/End\n");
for (i = 0; i < 4; i++) {
glBegin(GL_TRIANGLES);
for (j = 0; j < 3; j++) {
glColor3fv(array + i*15 + j*5 + 2);
glSecondaryColor3fv(seccol);
glVertex2fv(array + i*15 + j*5);
}
glEnd();
}
/* State change: Constant buffer. */
glTranslatef(0, 30, 0);
rotate_colors(array);
/* Create display lists. */
for (i = 0; i < 4; i++) {
glNewList(i+1, GL_COMPILE);
glBegin(GL_TRIANGLES);
for (j = 0; j < 3; j++) {
glColor3fv(array + i*15 + j*5 + 2);
glSecondaryColor3fv(seccol);
glVertex2fv(array + i*15 + j*5);
}
glEnd();
glEndList();
}
/* Draw. */
printf("CallList\n");
for (i = 0; i < 4; i++) {
glCallList(i+1);
}
pass = pass && piglit_probe_pixel_rgb(15, 15, c0);
pass = pass && piglit_probe_pixel_rgb(35, 15, c1);
pass = pass && piglit_probe_pixel_rgb(55, 15, c2);
pass = pass && piglit_probe_pixel_rgb(75, 15, c3);
pass = pass && piglit_probe_pixel_rgb(15, 45, c1);
pass = pass && piglit_probe_pixel_rgb(35, 45, c2);
pass = pass && piglit_probe_pixel_rgb(55, 45, c3);
pass = pass && piglit_probe_pixel_rgb(75, 45, c0);
pass = pass && piglit_probe_pixel_rgb(15, 75, c2);
pass = pass && piglit_probe_pixel_rgb(35, 75, c3);
pass = pass && piglit_probe_pixel_rgb(55, 75, c0);
pass = pass && piglit_probe_pixel_rgb(75, 75, c1);
pass = pass && piglit_probe_pixel_rgb(15, 105, c3);
pass = pass && piglit_probe_pixel_rgb(35, 105, c0);
pass = pass && piglit_probe_pixel_rgb(55, 105, c1);
pass = pass && piglit_probe_pixel_rgb(75, 105, c2);
glutSwapBuffers();
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
|