1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/attribs/gl-enable-vertex-attrib.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +<!-- 1.5 +// Copyright (c) 2011 The Chromium Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +--> 1.9 +<!DOCTYPE html> 1.10 +<html> 1.11 + <head> 1.12 +<meta charset="utf-8"> 1.13 + <title>WebGL Enable Vertex Attrib Test</title> 1.14 + <link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.15 + <script src="../../resources/js-test-pre.js"></script> 1.16 + <script src="../resources/webgl-test.js"> </script> 1.17 +</head> 1.18 +<body> 1.19 +<canvas id="example" width="50" height="50"> 1.20 +</canvas> 1.21 +<div id="description"></div> 1.22 +<div id="console"></div> 1.23 +<script id="vshader" type="x-shader/x-vertex"> 1.24 + attribute vec4 vPosition; 1.25 + void main() 1.26 + { 1.27 + gl_Position = vPosition; 1.28 + } 1.29 +</script> 1.30 + 1.31 +<script id="fshader" type="x-shader/x-fragment"> 1.32 + void main() 1.33 + { 1.34 + gl_FragColor = vec4(1.0,0.0,0.0,1.0); 1.35 + } 1.36 +</script> 1.37 + 1.38 +<script> 1.39 +description("tests that turning on attribs that have no buffer bound fails to draw"); 1.40 +gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1); 1.41 + 1.42 +var vertexObject = gl.createBuffer(); 1.43 +gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); 1.44 +gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW); 1.45 +gl.enableVertexAttribArray(0); 1.46 +gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); 1.47 + 1.48 +gl.enableVertexAttribArray(3); 1.49 +glErrorShouldBe(gl, gl.NO_ERROR); 1.50 + 1.51 +gl.drawArrays(gl.TRIANGLES, 0, 3); 1.52 +glErrorShouldBe(gl, gl.INVALID_OPERATION); 1.53 + 1.54 +successfullyParsed = true; 1.55 +</script> 1.56 +<script>finishTest();</script> 1.57 + 1.58 +</body> 1.59 +</html> 1.60 +