content/canvas/test/webgl-conformance/conformance/attribs/gl-enable-vertex-attrib.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 <!--
     2 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
     3 // Use of this source code is governed by a BSD-style license that can be
     4 // found in the LICENSE file.
     5 -->
     6 <!DOCTYPE html>
     7 <html>
     8   <head>
     9 <meta charset="utf-8">
    10     <title>WebGL Enable Vertex Attrib Test</title>
    11     <link rel="stylesheet" href="../../resources/js-test-style.css"/>
    12     <script src="../../resources/js-test-pre.js"></script>
    13     <script src="../resources/webgl-test.js"> </script>
    14 </head>
    15 <body>
    16 <canvas id="example" width="50" height="50">
    17 </canvas>
    18 <div id="description"></div>
    19 <div id="console"></div>
    20 <script id="vshader" type="x-shader/x-vertex">
    21     attribute vec4 vPosition;
    22     void main()
    23     {
    24         gl_Position = vPosition;
    25     }
    26 </script>
    28 <script id="fshader" type="x-shader/x-fragment">
    29     void main()
    30     {
    31         gl_FragColor = vec4(1.0,0.0,0.0,1.0);
    32     }
    33 </script>
    35 <script>
    36 description("tests that turning on attribs that have no buffer bound fails to draw");
    37 gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
    39 var vertexObject = gl.createBuffer();
    40 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
    41 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);
    42 gl.enableVertexAttribArray(0);
    43 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
    45 gl.enableVertexAttribArray(3);
    46 glErrorShouldBe(gl, gl.NO_ERROR);
    48 gl.drawArrays(gl.TRIANGLES, 0, 3);
    49 glErrorShouldBe(gl, gl.INVALID_OPERATION);
    51 successfullyParsed = true;
    52 </script>
    53 <script>finishTest();</script>
    55 </body>
    56 </html>

mercurial