4 ** Copyright (c) 2012 The Khronos Group Inc.
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
31 <meta charset="utf-8">
32 <title>Driver Bug - Uniforms should no lose values</title>
33 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
34 <script src="../../../resources/js-test-pre.js"></script>
35 <script src="../../resources/webgl-test-utils.js"></script>
38 <canvas id="canvas" width="512" height="256"> </canvas>
39 <div id="description"></div>
40 <div id="console"></div>
41 <script id="vshader" type="x-shader/x-vertex">
46 gl_Position=l*vec4(a,1.+u+k);
49 <script id="fshader" type="x-shader/x-fragment">
50 precision mediump float;
51 uniform float w,x,y,z;
53 gl_FragColor=vec4(1.-y,y,w+x+z,1);
58 // Certain drivers fail this test. Specifically Mac NVidia GT 330 on OSX 10.8.2
61 var wtu = WebGLTestUtils;
63 var gl = wtu.create3DContext("canvas");
65 testFailed("context does not exist");
69 wtu.setupUnitQuad(gl);
70 var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["a"], undefined, true);
72 var setUniformf = function(name, val) {
73 var loc = gl.getUniformLocation(program, name);
74 var func = 'uniform' + val.length + 'fv';
78 var setUniformMat = function(name, val) {
79 var loc = gl.getUniformLocation(program, name);
80 var func = 'uniformMatrix' + Math.sqrt(val.length) + 'fv';
81 gl[func](loc, false, val);
84 setUniformMat('l', [1, 0 ,0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
85 gl.viewport(0, 0, 256, 256);
86 setUniformf('y', [0]);
88 gl.viewport(256, 0, 256, 256);
89 setUniformf('y', [1]);
91 wtu.checkCanvasRect(gl, 0, 0, 256, 256, [255, 0, 0, 255]);
92 wtu.checkCanvasRect(gl, 256, 0, 256, 256, [0, 255, 0, 255]);
94 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
97 var successfullyParsed = true;
99 <script src="../../../resources/js-test-post.js"></script>