context-release-upon-reload-child.html (1450B)
1 <!-- 2 Copyright (c) 2019 The Khronos Group Inc. 3 Use of this source code is governed by an MIT-style license that can be 4 found in the LICENSE.txt file. 5 --> 6 7 <!DOCTYPE html> 8 <html style="margin: 0; padding: 0;"> 9 <head> 10 <meta charset="utf-8"> 11 <title>Simple WebGL context</title> 12 <script src="../../../js/webgl-test-utils.js"> </script> 13 </head> 14 <body style="margin: 0; padding: 0; overflow: hidden;"> 15 <canvas id="c" width="1680" height="1050" style="width: 256px; height: 256px;"> <!-- scaled to fit page better --> 16 <script id="vshader" type="x-shader/x-vertex"> 17 attribute vec4 vPosition; 18 void main() 19 { 20 gl_Position = vPosition; 21 } 22 </script> 23 24 <script id="fshader" type="x-shader/x-fragment"> 25 void main() 26 { 27 gl_FragColor = vec4(1.0,0.0,0.0,1.0); 28 } 29 </script> 30 31 <script> 32 "use strict"; 33 var wtu = WebGLTestUtils; 34 35 var gl = wtu.create3DContext("c", { antialias: false }); 36 var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]); 37 38 var vertexObject = gl.createBuffer(); 39 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); 40 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.75,0, -0.75,-0.75,0, 0.75,-0.75,0 ]), gl.STATIC_DRAW); 41 gl.enableVertexAttribArray(0); 42 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); 43 44 gl.clearColor(0.0, 0.0, 0.0, 1.0); 45 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 46 gl.drawArrays(gl.TRIANGLES, 0, 3); 47 48 if (parent) { 49 window.glContext = gl; 50 parent.postMessage("Ready", "*"); 51 } 52 </script> 53 </body> 54 </html>