2 * Copyright © 2010 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 DEALINGS
24 * Eric Anholt <eric@anholt.net>
28 /** @file glsl-vs-normalscale.c
30 * Tests that gl_NormalScale provides a correct value.
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
;
41 PIGLIT_GL_TEST_CONFIG_END
48 GLboolean pass
= GL_TRUE
;
49 static const float gray
[] = {0.5, 0.5, 0.5, 0.5};
51 /* Go ahead and draw with one matrix (gl_NormalScale = 1.0)
52 * first. Don't bother testing this one.
54 piglit_ortho_projection(1, 1, GL_FALSE
);
55 piglit_draw_rect(0, 0, 1, 1);
57 /* Tweak the modelview and draw over it with another matrix. */
58 glMatrixMode(GL_MODELVIEW
);
59 glScalef(1.0, 1.0, 0.5);
60 piglit_draw_rect(0, 0, 1, 1);
62 pass
= piglit_probe_rect_rgba(0, 0, piglit_width
, piglit_height
,
65 piglit_present_results();
67 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
70 void piglit_init(int argc
, char **argv
)
75 piglit_require_gl_version(20);
77 vs
= piglit_compile_shader(GL_VERTEX_SHADER
,
78 "shaders/glsl-vs-normalscale.vert");
79 fs
= piglit_compile_shader(GL_FRAGMENT_SHADER
,
80 "shaders/glsl-color.frag");
82 prog
= piglit_link_simple_program(vs
, fs
);
86 loc
= glGetUniformLocation(prog
, "sampler");