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
21 * DEALINGS IN THE SOFTWARE.
25 * \file glsl-fs-flat-color.c
26 * Test that gl_Color works correctly with GL_SHADE_MODEL of GL_FLAT
28 #include "piglit-util-gl.h"
30 PIGLIT_GL_TEST_CONFIG_BEGIN
32 config
.supports_gl_compat_version
= 10;
34 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
35 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
37 PIGLIT_GL_TEST_CONFIG_END
42 draw_rect(float x
, float y
, float w
, float h
, float *color
)
64 /* Fill in just the first color. We're flat shading, after all. */
65 memset(&colors
, 0, sizeof(colors
));
66 memcpy(colors
, color
, 4 * sizeof(float));
68 glVertexPointer(4, GL_FLOAT
, 0, verts
);
69 glEnableClientState(GL_VERTEX_ARRAY
);
70 glColorPointer(4, GL_FLOAT
, 0, colors
);
71 glEnableClientState(GL_COLOR_ARRAY
);
73 glDrawArrays(GL_POLYGON
, 0, 4);
75 glDisableClientState(GL_VERTEX_ARRAY
);
76 glDisableClientState(GL_COLOR_ARRAY
);
82 float green
[4] = { 0.0, 1.0, 0.0, 1.0 };
83 enum piglit_result result
= PIGLIT_PASS
;
85 glShadeModel(GL_FLAT
);
87 draw_rect(-1, -1, 2, 2, green
);
89 if (!piglit_probe_rect_rgba(0, 0, piglit_width
, piglit_height
, green
))
92 if (!piglit_automatic
)
93 piglit_present_results();
99 piglit_init(int argc
, char **argv
)
103 piglit_require_gl_version(20);
105 vs
= piglit_compile_shader(GL_VERTEX_SHADER
,
106 "shaders/glsl-color-mvp.vert");
107 fs
= piglit_compile_shader(GL_FRAGMENT_SHADER
,
108 "shaders/glsl-color.frag");
110 prog
= piglit_link_simple_program(vs
, fs
);
115 /* Don't try to render if the program failed to link, and linking
116 * had better succeed!
118 if (!piglit_link_check_status(prog
))
119 piglit_report_result(PIGLIT_FAIL
);