3 ** Copyright (c) 2014 The Khronos Group Inc.
\r
5 ** Permission is hereby granted, free of charge, to any person obtaining a
\r
6 ** copy of this software and/or associated documentation files (the
\r
7 ** "Materials"), to deal in the Materials without restriction, including
\r
8 ** without limitation the rights to use, copy, modify, merge, publish,
\r
9 ** distribute, sublicense, and/or sell copies of the Materials, and to
\r
10 ** permit persons to whom the Materials are furnished to do so, subject to
\r
11 ** the following conditions:
\r
13 ** The above copyright notice and this permission notice shall be included
\r
14 ** in all copies or substantial portions of the Materials.
\r
16 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
17 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
18 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
\r
19 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
\r
20 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
\r
21 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
\r
22 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
\r
28 <meta charset="utf-8">
\r
29 <link rel="stylesheet" href="../../../resources/js-test-style.css" />
\r
30 <link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
\r
31 <script src="../../../resources/js-test-pre.js"></script>
\r
32 <script src="../../resources/webgl-test-utils.js"></script>
\r
33 <script src="../../resources/glsl-conformance-test.js"></script>
\r
34 <title>Ternary Operators in Global Initializers</title>
\r
37 <div id="description"></div>
\r
38 <div id="console"></div>
\r
39 <script id="fragmentShader" type="text/something-not-javascript">
\r
40 precision mediump float;
\r
41 $(type) green = $(green);
\r
42 $(type) black = $(black);
\r
43 $(type) var = (true) ? green : black;
\r
45 gl_FragColor = $(asVec4);
\r
50 description("This test verifies that ternary operators can be used in global initializers.");
\r
52 var wtu = WebGLTestUtils;
\r
54 { type: 'float', green: '1.0', black: '0.0', asVec4: 'vec4(0.0,var,0.0,1.0)' },
\r
55 { type: 'vec2', green: 'vec2(0.0,1.0)', black: 'vec2(0.0,0.0)', asVec4: 'vec4(var,0.0,1.0)' },
\r
56 { type: 'vec3', green: 'vec3(0.0,1.0,0.0)', black: 'vec3(0.0,0.0,0.0)', asVec4: 'vec4(var,1.0)' },
\r
57 { type: 'vec4', green: 'vec4(0.0,1.0,0.0,1.0)', black: 'vec4(0.0,0.0,0.0,0.0)', asVec4: 'var' },
\r
58 { type: 'int', green: '1', black: '0', asVec4: 'vec4(0.0,var,0.0,1.0)' },
\r
59 { type: 'ivec2', green: 'ivec2(0,1)', black: 'ivec2(0,0)', asVec4: 'vec4(var,0.0,1.0)' },
\r
60 { type: 'ivec3', green: 'ivec3(0,1,0)', black: 'ivec3(0,0,0)', asVec4: 'vec4(var,1.0)' },
\r
61 { type: 'ivec4', green: 'ivec4(0,1,0,1)', black: 'ivec4(0,0,0,0)', asVec4: 'vec4(var)' },
\r
62 { type: 'bool', green: 'true', black: 'false', asVec4: 'vec4(0.0,var,0.0,1.0)' },
\r
63 { type: 'bvec2', green: 'bvec2(false,true)', black: 'bvec2(false,false)', asVec4: 'vec4(var,0.0,1.0)' },
\r
64 { type: 'bvec3', green: 'bvec3(false,true,false)', black: 'bvec3(false,false,false)', asVec4: 'vec4(var,1.0)' },
\r
65 { type: 'bvec4', green: 'bvec4(false,true,false,true)',black: 'bvec4(false,false,false,false)', asVec4: 'vec4(var)' },
\r
67 typeInfos.forEach(function (typeInfo) {
\r
68 var replaceParams = {
\r
69 type: typeInfo.type,
\r
70 green: typeInfo.green,
\r
71 black: typeInfo.black,
\r
72 asVec4: typeInfo.asVec4,
\r
75 fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
\r
76 passMsg: typeInfo.type,
\r
77 fShaderSuccess: true,
\r
82 GLSLConformanceTester.runTests(tests);
\r
83 var successfullyParsed = true;
\r