2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>Matrix compound multiplication test
</title>
12 <link rel=
"stylesheet" href=
"../../../resources/js-test-style.css"/>
13 <script src=
"../../../js/js-test-pre.js"></script>
14 <script src=
"../../../js/webgl-test-utils.js"></script>
17 <canvas id=
"canvas" width=
"256" height=
"256"> </canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
20 <script id=
"vshader" type=
"x-shader/x-vertex">
21 attribute vec3 aPosition;
24 gl_Position = vec4(aPosition,
1);
27 <script id=
"fshader" type=
"x-shader/x-fragment">
28 precision mediump float;
31 $(type) a = $(type)(
0.0);
32 $(type) b = $(type)(
0.0);
33 a[
1][
1] =
3.0; //
2nd column,
2nd row
34 b[
0][
1] =
2.0; //
1st column,
2nd row
37 $(type) diffMat = a - c;
38 float diff = length(diffMat[
0]) + length(diffMat[
1]);
39 gl_FragColor = vec4(
0.0, diff <
0.01 ?
1.0 :
0.0,
0.0,
1.0);
42 <script type=
"application/javascript">
44 description(
"Matrix compound multiplication test comparing against normal multiplication.");
46 var wtu = WebGLTestUtils;
48 var gl = wtu.create3DContext(
"canvas");
50 testFailed(
"context does not exist");
53 wtu.setupUnitQuad(gl);
54 var fshaderTemplate = wtu.getScript('fshader');
56 var types = ['mat2', 'mat3', 'mat4'];
57 for (var i =
0; i < types.length; ++i) {
59 debug('Testing type ' + types[i]);
60 var fshaderSource = wtu.replaceParams(fshaderTemplate, {type: types[i]});
61 var program = wtu.setupProgram(gl, ['vshader', fshaderSource], [
"aPosition"], undefined, true);
63 wtu.checkCanvas(gl, [
0,
255,
0,
255], 'should be green');