Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <!-- |
michael@0 | 2 | Copyright (c) 2011 The Chromium Authors. All rights reserved. |
michael@0 | 3 | Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | found in the LICENSE file. |
michael@0 | 5 | --> |
michael@0 | 6 | <!DOCTYPE html> |
michael@0 | 7 | <html> |
michael@0 | 8 | <head> |
michael@0 | 9 | <meta charset="utf-8"> |
michael@0 | 10 | <title>WebGL drawElements Test</title> |
michael@0 | 11 | <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
michael@0 | 12 | <script src="../../resources/js-test-pre.js"></script> |
michael@0 | 13 | <script src="../resources/webgl-test.js"> </script> |
michael@0 | 14 | <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script> |
michael@0 | 15 | </head> |
michael@0 | 16 | <body> |
michael@0 | 17 | <canvas id="example" width="50" height="50"></canvas> |
michael@0 | 18 | <div id="description"></div> |
michael@0 | 19 | <div id="console"></div> |
michael@0 | 20 | <script id="vshader" type="x-shader/x-vertex"> |
michael@0 | 21 | attribute vec4 vPosition; |
michael@0 | 22 | void main() |
michael@0 | 23 | { |
michael@0 | 24 | gl_Position = vPosition; |
michael@0 | 25 | } |
michael@0 | 26 | </script> |
michael@0 | 27 | |
michael@0 | 28 | <script id="fshader" type="x-shader/x-fragment"> |
michael@0 | 29 | void main() |
michael@0 | 30 | { |
michael@0 | 31 | gl_FragColor = vec4(1.0,0.0,0.0,1.0); |
michael@0 | 32 | } |
michael@0 | 33 | </script> |
michael@0 | 34 | |
michael@0 | 35 | <script> |
michael@0 | 36 | function init() |
michael@0 | 37 | { |
michael@0 | 38 | if (window.initNonKhronosFramework) { |
michael@0 | 39 | window.initNonKhronosFramework(false); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | description(document.title); |
michael@0 | 43 | |
michael@0 | 44 | function checkDrawElements(mode, count, type, expect, msg) { |
michael@0 | 45 | gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
michael@0 | 46 | gl.drawElements(mode, count, type, 0); |
michael@0 | 47 | glErrorShouldBe(gl, expect, msg); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1); |
michael@0 | 51 | |
michael@0 | 52 | var vertexObject = gl.createBuffer(); |
michael@0 | 53 | gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); |
michael@0 | 54 | gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW); |
michael@0 | 55 | gl.enableVertexAttribArray(0); |
michael@0 | 56 | gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); |
michael@0 | 57 | |
michael@0 | 58 | var vertexObject = gl.createBuffer(); |
michael@0 | 59 | gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexObject); |
michael@0 | 60 | gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 0, 1, 2]), gl.STATIC_DRAW); |
michael@0 | 61 | |
michael@0 | 62 | checkDrawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, |
michael@0 | 63 | gl.NO_ERROR, "can call gl.DrawElements with UNSIGNED_SHORT"); |
michael@0 | 64 | |
michael@0 | 65 | var vertexObject = gl.createBuffer(); |
michael@0 | 66 | gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexObject); |
michael@0 | 67 | gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([ 0, 1, 2, 0]), gl.STATIC_DRAW); |
michael@0 | 68 | |
michael@0 | 69 | checkDrawElements( |
michael@0 | 70 | gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, |
michael@0 | 71 | gl.NO_ERROR, "can call gl.DrawElements with UNSIGNED_BYTE"); |
michael@0 | 72 | checkDrawElements( |
michael@0 | 73 | desktopGL['QUAD_STRIP'], 4, gl.UNSIGNED_BYTE, |
michael@0 | 74 | gl.INVALID_ENUM, "gl.DrawElements with QUAD_STRIP should return INVALID_ENUM"); |
michael@0 | 75 | checkDrawElements( |
michael@0 | 76 | desktopGL['QUADS'], 4, gl.UNSIGNED_BYTE, |
michael@0 | 77 | gl.INVALID_ENUM, "gl.DrawElements with QUADS should return INVALID_ENUM"); |
michael@0 | 78 | checkDrawElements( |
michael@0 | 79 | desktopGL['POLYGON'], 4, gl.UNSIGNED_BYTE, |
michael@0 | 80 | gl.INVALID_ENUM, "gl.DrawElements with POLYGON should return INVALID_ENUM"); |
michael@0 | 81 | |
michael@0 | 82 | var vertexObject = gl.createBuffer(); |
michael@0 | 83 | gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexObject); |
michael@0 | 84 | gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ 0, 1, 2]), gl.STATIC_DRAW); |
michael@0 | 85 | |
michael@0 | 86 | checkDrawElements( |
michael@0 | 87 | gl.TRIANGLES, 3, gl.UNSIGNED_INT, |
michael@0 | 88 | gl.INVALID_ENUM, "gl.DrawElements should return INVALID_ENUM with UNSIGNED_INT"); |
michael@0 | 89 | |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | init(); |
michael@0 | 93 | successfullyParsed = true; |
michael@0 | 94 | </script> |
michael@0 | 95 | <script>finishTest();</script> |
michael@0 | 96 | |
michael@0 | 97 | </body> |
michael@0 | 98 | </html> |