active-built-in-attribs.html (2261B)
1 <!-- 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. 5 --> 6 7 <!DOCTYPE html> 8 <html> 9 <head> 10 <meta charset="utf-8"> 11 <title>WebGL Conformance Tests: Verify validation for active built-in attribs</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> 16 </head> 17 <body> 18 <div id="description"></div> 19 <canvas id="canvas" style="width: 64px; height: 64px;"> </canvas> 20 <div id="console"></div> 21 <script id="vs" type="x-shader/x-vertex">#version 300 es 22 void main() { 23 gl_Position = vec4(gl_VertexID % 2, (gl_VertexID/2) % 2, 0, 1); 24 } 25 </script> 26 27 <script id="fs" type="x-shader/x-fragment">#version 300 es 28 precision mediump float; 29 out vec4 fragColor; 30 void main() { 31 fragColor = vec4(0, 1, 0, 1); 32 } 33 </script> 34 35 <script> 36 "use strict"; 37 description("This test verifies validation for active built-in attribs."); 38 39 debug(""); 40 41 var wtu = WebGLTestUtils; 42 var canvas = document.getElementById("canvas"); 43 var gl = wtu.create3DContext(canvas, null, 2); 44 45 if (!gl) { 46 testFailed("WebGL context does not exist"); 47 } else { 48 testPassed("WebGL context exists"); 49 runTests(); 50 } 51 52 var activeInfo, attribLoc; 53 54 function runTests() { 55 var prog = wtu.setupProgram(gl, ["vs", "fs"]); 56 if (!prog) { 57 testFailed("Set up program failed"); 58 return; 59 } 60 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "No GL error from set up"); 61 62 var numActive = gl.getProgramParameter(prog, gl.ACTIVE_ATTRIBUTES); 63 if (numActive != 1) { 64 testFailed('ACTIVE_ATTRIBUTES should be 1.'); 65 return; 66 } 67 testPassed('ACTIVE_ATTRIBUTES should be 1.'); 68 69 activeInfo = gl.getActiveAttrib(prog, 0); 70 if (!activeInfo) { 71 testFailed('getActiveAttrib should return an info object.'); 72 return; 73 } 74 75 shouldBe('activeInfo.name', '"gl_VertexID"'); 76 attribLoc = gl.getAttribLocation(prog, 'gl_VertexID'); 77 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be able to request the location of a built-in."); 78 shouldBe('attribLoc', '-1'); 79 } 80 81 var successfullyParsed = true; 82 </script> 83 <script src="../../js/js-test-post.js"></script> 84 85 </body> 86 </html>