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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/renderbuffers/framebuffer-state-restoration.html

Issue 10399113: Roll webgl conformance tests to r17874: part 2, adding r17874 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 7 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8">
32 <title>WebGL Framebuffer state restoration Test</title>
33 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
34 <script src="../../resources/js-test-pre.js"></script>
35 <script src="../resources/webgl-test.js"> </script>
36 <script src="../resources/webgl-test-utils.js"> </script>
37 </head>
38 <body>
39 <canvas id="example" width="50" height="50">
40 </canvas>
41 <div id="description"></div>
42 <div id="console"></div>
43 <script>
44 var wtu = WebGLTestUtils;
45 description();
46
47 function test() {
48 gl = wtu.create3DContext("example", {preserveDrawingBuffer: true});
49 var program = wtu.setupColorQuad(gl);
50 var colorLoc = gl.getUniformLocation(program, "u_color");
51 gl.enable(gl.DEPTH_TEST);
52 gl.depthFunc(gl.LESS);
53
54 var testDrawToBackBuffer = function(label) {
55 debug("");
56 debug("drawing to backbuffer " + label);
57 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
58 // Draw in green
59 gl.uniform4fv(colorLoc, [0, 1, 0, 1]);
60 gl.drawArrays(gl.TRIANGLES, 0, 6);
61 wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
62 // Draw in red, should not draw because of depth test.
63 gl.uniform4fv(colorLoc, [1, 0, 0, 1]);
64 gl.drawArrays(gl.TRIANGLES, 0, 6);
65 wtu.checkCanvas(gl, [0, 255, 0, 255], "should still be green");
66 }
67
68 var testDrawToFBO = function(label ) {
69 debug("");
70 debug("drawing to framebuffer " + label);
71 // Draw in green
72 gl.uniform4fv(colorLoc, [0, 1, 0, 1]);
73 gl.drawArrays(gl.TRIANGLES, 0, 6);
74 wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
75 // Draw in red as there is not depth buffer.
76 gl.uniform4fv(colorLoc, [1, 0, 0, 1]);
77 gl.drawArrays(gl.TRIANGLES, 0, 6);
78 wtu.checkCanvas(gl, [255, 0, 0, 255], "should be red");
79 }
80
81 testDrawToBackBuffer("start");
82
83 var fbo = gl.createFramebuffer();
84 var tex = gl.createTexture();
85 gl.bindTexture(gl.TEXTURE_2D, tex);
86 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 50, 50, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
87 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
88 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
89 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
90 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
91 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
92 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, t ex, 0);
93 if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
94 finishTest();
95 return;
96 }
97
98 wtu.checkCanvas(gl, [0, 0, 0, 0], "should be zero");
99 testDrawToFBO("start");
100
101 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
102 testDrawToBackBuffer("after drawing to framebuffer");
103
104 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
105 testDrawToFBO("after drawing to backbuffer");
106
107 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
108 wtu.waitFrames(5, function() {
109 testDrawToBackBuffer("after composite");
110 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
111 testDrawToFBO("after drawing to backbuffer after composite");
112 wtu.waitFrames(5, function() {
113 testDrawToFBO("after composite");
114 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
115 testDrawToBackBuffer("after drawing to framebuffer after composite");
116
117 glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
118 finishTest();
119 });
120 });
121 }
122 test();
123
124 successfullyParsed = true;
125 </script>
126 </body>
127 </html>
128
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698