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

Side by Side Diff: third_party/webgl/sdk/tests/conformance/renderbuffers/renderbuffer-initialization.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 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
33 <script src="../../resources/js-test-pre.js"></script>
34 <script src="../resources/webgl-test.js"></script>
35 <script src="../resources/webgl-test-utils.js"></script>
36 </head>
37 <body>
38 <canvas id="testbed" width="400" height="400" style="width: 40px; height: 40px;" ></canvas>
39 <div id="description"></div>
40 <div id="console"></div>
41 <script>
42 var wtu = WebGLTestUtils;
43 description('Verify renderbuffers are initialized to 0 before being read in WebG L');
44
45 var gl = wtu.create3DContext("testbed");
46 if (!gl) {
47 testFailed('canvas.getContext() failed');
48 } else {
49 // Set the clear color to green. It should never show up.
50 gl.clearColor(0, 1, 0, 1);
51
52 runTest(gl, gl.canvas.width, gl.canvas.height, 0);
53 runTest(gl, gl.canvas.width, gl.canvas.height, 1);
54 runTest(gl, gl.canvas.width, gl.canvas.height, 0);
55 runTest(gl, gl.canvas.width, gl.canvas.height, 1);
56
57 // Testing buffer clearing won't change the clear values.
58 var clearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE);
59 shouldBe("clearColor", "[0, 1, 0, 1]");
60 glErrorShouldBe(gl, gl.NO_ERROR, 'should be no errors');
61 }
62
63 function runTest(gl, width, height, order)
64 {
65 wtu.checkCanvasRect(gl, 0, 0, width, height, [0,0,0,0],
66 "internal buffers have been initialized to 0");
67
68 // fill the back buffer so we know that reading below happens from
69 // the renderbuffer.
70 gl.clear(gl.COLOR_BUFFER_BIT);
71
72 var fbo = gl.createFramebuffer();
73 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
74 var colorbuffer = gl.createRenderbuffer();
75 gl.bindRenderbuffer(gl.RENDERBUFFER, colorbuffer);
76 switch (order) {
77 case 0:
78 allocStorage(width, height);
79 attachBuffer(colorbuffer);
80 break;
81 case 1:
82 attachBuffer(colorbuffer);
83 allocStorage(width, height);
84 break;
85 }
86
87 function allocStorage(width, height) {
88 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, width, height);
89 glErrorShouldBe(gl, gl.NO_ERROR, 'should be no error after renderbufferSto rage(internalformat = RGBA4).');
90 }
91
92 function attachBuffer(colorbuffer) {
93 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDER BUFFER, colorbuffer);
94 }
95
96 if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
97 testFailed('Framebuffer incomplete.');
98 return;
99 }
100
101 wtu.checkCanvasRect(gl, 0, 0, width, height, [0,0,0,0],
102 "user buffers have been initialized to 0");
103
104 gl.deleteFramebuffer(fbo);
105 gl.deleteRenderbuffer(colorbuffer);
106
107 // this clear should not matter we are about to resize
108 gl.clear(gl.COLOR_BUFFER_BIT);
109
110 gl.canvas.width += 1;
111 gl.canvas.height += 1;
112
113 debug('');
114 }
115
116 successfullyParsed = true;
117 </script>
118 <script src="../../resources/js-test-post.js"></script>
119 </body>
120 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698