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

Side by Side Diff: misc/program-test-1.html

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 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
« no previous file with comments | « extra/webgl-info.html ('k') | resources/desktop-gl-constants.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
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 <meta charset="utf-8">
10 <!-- This is a visual test that programs must have both a vertex and
11 fragment shader attached; the fixed function pipeline on the
12 desktop must remain disabled. -->
13 <script type="text/javascript">
14 function log() {
15 var s = "";
16 for (var i = 0; i < arguments.length; ++i) {
17 s += arguments[i] + " ";
18 }
19
20 document.getElementById("log").innerHTML += s + "<br>";
21 }
22
23 function go() {
24 var gl = document.getElementById("c").getContext("experimental-webgl");
25
26 gl.clearColor(0.0, 0.0, 0.0, 0.0);
27 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
28
29 var vs = gl.createShader(gl.VERTEX_SHADER);
30 gl.shaderSource(vs, "attribute vec4 aVertex; attribute vec4 aColor; vary ing vec4 vColor; void main() { vColor = aColor; gl_Position = aVertex; }");
31 gl.compileShader(vs);
32
33 var fs = gl.createShader(gl.FRAGMENT_SHADER);
34 gl.shaderSource(fs, "precision mediump float; varying vec4 vColor; void main() { gl_FragColor = vColor; }");
35 gl.compileShader(fs);
36
37 var prog = gl.createProgram();
38 gl.attachShader(prog, vs);
39 // don't attach a fragment shader -- may use fixed pipeline on desktop i f the implementation doesn't check!
40 //gl.attachShader(prog, fs);
41
42 gl.bindAttribLocation(prog, 0, "aVertex");
43 gl.bindAttribLocation(prog, 1, "aColor");
44
45 gl.linkProgram(prog);
46
47 var vbuf = gl.createBuffer();
48 gl.bindBuffer(gl.ARRAY_BUFFER, vbuf);
49 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
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,
53 1.0, 1.0, 0.0, 1.0]) , gl.STATIC_DRAW);
54 gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 0);
55
56 var cbuf = gl.createBuffer();
57 gl.bindBuffer(gl.ARRAY_BUFFER, cbuf);
58 gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([255, 0, 0,
59 0, 255, 0,
60 0, 0, 255,
61 255, 255, 0]) , gl.STATIC_DRAW);
62 gl.vertexAttribPointer(1, 3, gl.UNSIGNED_BYTE, false, 0, 0);
63
64 gl.enableVertexAttribArray(0);
65 gl.enableVertexAttribArray(1);
66
67 gl.useProgram(prog);
68
69 gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
70
71 log("glError", "0x" + gl.getError().toString(16));
72 }
73 </script>
74 </head>
75
76 <body onload="go()">
77 <p>Should be green in the rectangle below:</p>
78 <canvas style="background: green;" id="c"></canvas>
79 <div id="log"></div>
80 </body>
81 </html>
OLDNEW
« no previous file with comments | « extra/webgl-info.html ('k') | resources/desktop-gl-constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698