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>Verify that line width limits are enforced.
</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=
"example" width=
"4" height=
"4" style=
"width: 40px; height: 30px;"></canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
22 description(document
.title
);
23 var wtu
= WebGLTestUtils
;
24 var gl
= wtu
.create3DContext("example");
26 // Query the line width range
27 var lineWidthRange
= gl
.getParameter(gl
.ALIASED_LINE_WIDTH_RANGE
);
28 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors.");
30 if (lineWidthRange
[0] > 1 || lineWidthRange
[1] < 1)
31 testFailed("Line width range must include width 1");
33 // Zero, negative, or NaN values should cause an error and leave the value unchanged.
34 var curLineWidth
= gl
.getParameter(gl
.LINE_WIDTH
);
36 wtu
.glErrorShouldBe(gl
, gl
.INVALID_VALUE
, "Should not be able to set lineWidth to zero");
37 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'curLineWidth'); // Previous value should be preserved
40 wtu
.glErrorShouldBe(gl
, gl
.INVALID_VALUE
, "Should not be able to set lineWidth to a negative value");
41 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'curLineWidth'); // Previous value should be preserved
44 wtu
.glErrorShouldBe(gl
, gl
.INVALID_VALUE
, "Should not be able to set lineWidth to NaN");
45 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'curLineWidth'); // Previous value should be preserved
47 // Check that the line width can be set to the valid range.
48 gl
.lineWidth(lineWidthRange
[1]);
49 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be able to set lineWidth to the max supported value");
50 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'lineWidthRange[1]');
52 gl
.lineWidth(lineWidthRange
[0]);
53 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be able to set lineWidth to the min supported value");
54 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'lineWidthRange[0]');
56 // Checks that the line width can be set outside the supported range without error,
57 // and the unclamped value can be queried back.
58 // Yes, this is actually what the spec says should happen.
59 // See: https://www.khronos.org/opengles/sdk/docs/man3/html/glLineWidth.xhtml
60 gl
.lineWidth(lineWidthRange
[1]+1);
61 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be able to set lineWidth to the above max supported value");
62 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'lineWidthRange[1]+1');
64 var successfullyParsed
= true;
67 <script src=
"../../js/js-test-post.js"></script>