conversion-explicit: use a different value for normalized +/- min
[piglit.git] / tests / spec / gl-1.2 / rescale-normal.c
blob8ebfebaae57a95297b94c14a06af9f705fc48f37
1 /*
2 * Copyright © 2017 Fabian Bieler
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 DEALINGS
21 * IN THE SOFTWARE.
24 /**
25 * @file rescale-normal.c: Rescale normals with fixed function pipeline.
27 * Set up scene with diffuse lighting and an isotropic modelview scale of 100.
28 * Set the light color to 1% red, 100% green, 0% blue.
29 * If the normal is scaled incorrectly in either direction, the sampled color
30 * would be black or yellow, respectively, instead of green.
33 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config.supports_gl_compat_version = 12;
38 config.window_visual = PIGLIT_GL_VISUAL_RGB;
39 config.khr_no_error_support = PIGLIT_NO_ERRORS;
41 PIGLIT_GL_TEST_CONFIG_END
43 static const float green_with_a_smitch_of_red[] = {0.01, 1, 0, 1};
45 enum piglit_result
46 piglit_display(void)
48 piglit_draw_rect(-0.01, -0.01, 0.02, 0.02);
49 bool pass = piglit_probe_pixel_rgb(piglit_width / 2,
50 piglit_height / 2,
51 green_with_a_smitch_of_red);
53 piglit_present_results();
55 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
58 void
59 piglit_init(int argc, char **argv)
61 const float black[] = {0, 0, 0, 1};
62 const float white[] = {1, 1, 1, 1};
64 glEnable(GL_LIGHTING);
65 glEnable(GL_LIGHT0);
67 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, black);
68 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, white);
70 glLightfv(GL_LIGHT0, GL_DIFFUSE, green_with_a_smitch_of_red);
72 glScalef(100.0, 100.0, 100.0);
73 glEnable(GL_RESCALE_NORMAL);
75 glNormal3f(0, 0, 1);