framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / shaders / glsl-fs-flat-color.c
blobd275207b954b3a225fef7f3fcc0d6e5d2fb6a780
1 /*
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
13 * Software.
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.
24 /**
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
39 GLuint prog;
41 GLvoid
42 draw_rect(float x, float y, float w, float h, float *color)
44 float verts[4][4];
45 float colors[16];
47 verts[0][0] = x;
48 verts[0][1] = y;
49 verts[0][2] = 0.0;
50 verts[0][3] = 1.0;
51 verts[1][0] = x + w;
52 verts[1][1] = y;
53 verts[1][2] = 0.0;
54 verts[1][3] = 1.0;
55 verts[2][0] = x + w;
56 verts[2][1] = y + h;
57 verts[2][2] = 0.0;
58 verts[2][3] = 1.0;
59 verts[3][0] = x;
60 verts[3][1] = y + h;
61 verts[3][2] = 0.0;
62 verts[3][3] = 1.0;
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);
79 enum piglit_result
80 piglit_display(void)
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))
90 result = PIGLIT_FAIL;
92 if (!piglit_automatic)
93 piglit_present_results();
95 return result;
98 void
99 piglit_init(int argc, char **argv)
101 GLuint vs, fs;
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);
112 glDeleteShader(vs);
113 glDeleteShader(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);
121 glUseProgram(prog);