2 * Copyright © 2011 VMware, Inc.
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
21 * DEALINGS IN THE SOFTWARE.
27 * Test glDrawArrays with glColorMaterial.
28 * This exercises a Mesa bug where glColor() calls didn't effect
29 * the color of lit surfaces when color material mode was used.
33 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config
.supports_gl_compat_version
= 10;
39 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
40 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
42 PIGLIT_GL_TEST_CONFIG_END
46 static GLfloat pos0
[4][3] =
48 { 0.5 + DX0
, -0.5, 0.0 },
49 { 0.5 + DX0
, 0.5, 0.0 },
50 { -0.5 + DX0
, 0.5, 0.0 },
51 { -0.5 + DX0
, -0.5, 0.0 }
56 static GLfloat pos1
[4][3] =
58 { 0.5 + DX1
, -0.5, 0.0 },
59 { 0.5 + DX1
, 0.5, 0.0 },
60 { -0.5 + DX1
, 0.5, 0.0 },
61 { -0.5 + DX1
, -0.5, 0.0 }
64 static GLfloat norms
[4][3] =
76 static const GLfloat red
[3] = {1.0f
, 0.0f
, 0.0f
};
77 static const GLfloat green
[3] = {0.0f
, 1.0f
, 0.0f
};
78 GLboolean pass
= GL_TRUE
;
80 glEnable(GL_LIGHTING
);
83 glEnable(GL_COLOR_MATERIAL
);
84 glColorMaterial(GL_FRONT_AND_BACK
, GL_AMBIENT_AND_DIFFUSE
);
86 glClearColor(0.3, 0.3, 0.3, 1);
87 glClear(GL_COLOR_BUFFER_BIT
);
91 glEnableClientState(GL_VERTEX_ARRAY
);
92 glEnableClientState(GL_NORMAL_ARRAY
);
93 glVertexPointer(3, GL_FLOAT
, 0, pos0
);
94 glNormalPointer(GL_FLOAT
, 0, norms
);
95 glDrawArrays(GL_TRIANGLE_FAN
, 0, 4);
99 glVertexPointer(3, GL_FLOAT
, 0, pos1
);
100 glNormalPointer(GL_FLOAT
, 0, norms
);
101 glDrawArrays(GL_TRIANGLE_FAN
, 0, 4);
103 glDisableClientState(GL_VERTEX_ARRAY
);
104 glDisableClientState(GL_NORMAL_ARRAY
);
106 glDisable(GL_LIGHTING
);
108 if (!piglit_probe_pixel_rgb(piglit_width
* 1 / 3,
109 piglit_height
/ 2, red
)) {
113 if (!piglit_probe_pixel_rgb(piglit_width
* 2 / 3,
114 piglit_height
/ 2, green
)) {
118 piglit_present_results();
120 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
125 piglit_init(int argc
, char **argv
)