Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/misc/program-test-1.html

Issue 9360034: Remove everthing except conformance tests in the deps/third_party/webgl (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2010 Mozilla Foundation. 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 <!-- This is a visual test that programs must have both a vertex and
10 fragment shader attached; the fixed function pipeline on the
11 desktop must remain disabled. -->
12 <script type="text/javascript">
13 function log() {
14 var s = "";
15 for (var i = 0; i < arguments.length; ++i) {
16 s += arguments[i] + " ";
17 }
18
19 document.getElementById("log").innerHTML += s + "<br>";
20 }
21
22 function go() {
23 var gl = document.getElementById("c").getContext("experimental-webgl");
24
25 gl.clearColor(0.0, 0.0, 0.0, 0.0);
26 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
27
28 var vs = gl.createShader(gl.VERTEX_SHADER);
29 gl.shaderSource(vs, "attribute vec4 aVertex; attribute vec4 aColor; vary ing vec4 vColor; void main() { vColor = aColor; gl_Position = aVertex; }");
30 gl.compileShader(vs);
31
32 var fs = gl.createShader(gl.FRAGMENT_SHADER);
33 gl.shaderSource(fs, "#ifdef GL_ES\nprecision mediump float;\n#endif\n va rying vec4 vColor; void main() { gl_FragColor = vColor; }");
34 gl.compileShader(fs);
35
36 var prog = gl.createProgram();
37 gl.attachShader(prog, vs);
38 // don't attach a fragment shader -- may use fixed pipeline on desktop i f the implementation doesn't check!
39 //gl.attachShader(prog, fs);
40
41 gl.bindAttribLocation(prog, 0, "aVertex");
42 gl.bindAttribLocation(prog, 1, "aColor");
43
44 gl.linkProgram(prog);
45
46 var vbuf = gl.createBuffer();
47 gl.bindBuffer(gl.ARRAY_BUFFER, vbuf);
48 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
49 -1.0, -1.0, 0.0, 1.0,
50 -1.0, 1.0, 0.0, 1.0,
51 1.0, -1.0, 0.0, 1.0,
52 1.0, 1.0, 0.0, 1.0]) , gl.STATIC_DRAW);
53 gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 0);
54
55 var cbuf = gl.createBuffer();
56 gl.bindBuffer(gl.ARRAY_BUFFER, cbuf);
57 gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([255, 0, 0,
58 0, 255, 0,
59 0, 0, 255,
60 255, 255, 0]) , gl.STATIC_DRAW);
61 gl.vertexAttribPointer(1, 3, gl.UNSIGNED_BYTE, false, 0, 0);
62
63 gl.enableVertexAttribArray(0);
64 gl.enableVertexAttribArray(1);
65
66 gl.useProgram(prog);
67
68 gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
69
70 log("glError", "0x" + gl.getError().toString(16));
71 }
72 </script>
73 </head>
74
75 <body onload="go()">
76 <p>Should be green in the rectangle below:</p>
77 <canvas style="background: green;" id="c"></canvas>
78 <div id="log"></div>
79 </body>
80 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698