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>WebGL ShaderL Conformance Tests
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/desktop-gl-constants.js"></script>
14 <script src=
"../../js/js-test-pre.js"></script>
15 <script src=
"../../js/webgl-test-utils.js"></script>
18 <script id=
"vs" type=
"x-shader/x-fragment">
19 attribute vec4 vPosition;
20 varying vec2 texCoord;
22 gl_Position = vPosition;
23 texCoord = vPosition.xy *
0.5 +
0.5;
26 <script id=
"fs-green" type=
"x-shader/x-fragment">
27 precision mediump float;
29 gl_FragData[
0] = vec4(
0,
1,
0,
1);
32 <script id=
"fs-red" type=
"x-shader/x-fragment">
33 precision mediump float;
35 gl_FragData[
0] = vec4(
1,
0,
0,
1);
38 <div id=
"description"></div>
39 <div id=
"console"></div>
40 <canvas id=
"canvas" width=
"2" height=
"2"> </canvas>
43 description("This test checks a few things about WebGL Shaders.");
46 debug("Canvas.getContext");
48 var wtu
= WebGLTestUtils
;
49 var gl
= wtu
.create3DContext("canvas");
51 testFailed("context does not exist");
53 testPassed("context exists");
56 debug("Checking shaders.");
58 // Create the shader object
59 var shader
= gl
.createShader(desktopGL
['GEOMETRY_SHADER_ARB']);
60 assertMsg(shader
== null,
61 "should not be able to create GEOMETRY shader");
63 checkDeferredCompliation()
66 function checkDeferredCompliation() {
67 var vs
= gl
.createShader(gl
.VERTEX_SHADER
);
68 gl
.shaderSource(vs
, document
.getElementById("vs").text
);
70 var fs
= gl
.createShader(gl
.FRAGMENT_SHADER
);
71 // Compile the green shader
72 gl
.shaderSource(fs
, document
.getElementById("fs-green").text
);
74 // Load the red shader source but do NOT compile it
75 gl
.shaderSource(fs
, document
.getElementById("fs-red").text
);
76 var p
= gl
.createProgram();
77 gl
.attachShader(p
, vs
);
78 gl
.attachShader(p
, fs
);
79 gl
.bindAttribLocation(p
, 0, "vPosition");
82 wtu
.setupUnitQuad(gl
, 0, 1);
83 wtu
.clearAndDrawUnitQuad(gl
);
84 wtu
.checkCanvas(gl
, [0, 255, 0, 255], "should be green");
88 var successfullyParsed
= true;
91 <script src=
"../../js/js-test-post.js"></script>