1<!DOCTYPE html> 2<title>Testing GMs on WebGL 2 compiled with Bazel</title> 3<meta charset="utf-8" /> 4<meta http-equiv="X-UA-Compatible" content="IE=edge"> 5<meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 7<script type="text/javascript" src="/build/gm-bindings.js"></script> 8 9<p id="log"></p> 10<!-- Makes png visible to user --> 11<canvas id=png_canvas height=1000 width=1000></canvas> 12<!-- Used for drawing/testing, but nothing is visible --> 13<canvas id=gm_canvas></canvas> 14 15 16<script type="text/javascript" charset="utf-8"> 17 function log(s) { 18 document.getElementById("log").innerText = s; 19 } 20 RunGMs(); 21 async function RunGMs() { 22 const GM = await InitWasmGMTests({locateFile: (file) => '/build/'+file}); 23 GM.Init(); 24 const names = GM.ListGMs(); 25 names.sort(); 26 27 const canvas = document.getElementById('gm_canvas'); 28 const ctx = GM.GetWebGLContext(canvas, 2); 29 const grcontext = GM.MakeGrContext(ctx); 30 31 log("Running gm "+ names[0]); 32 const pngAndMetadata = GM.RunGM(grcontext, names[0]); 33 34 const b = new Blob([pngAndMetadata.png.buffer], {type:"image/png"}); 35 const bmp = await createImageBitmap(b); 36 const canvasCtx = document.getElementById("png_canvas").getContext("2d"); 37 canvasCtx.drawImage(bmp, 0, 0); 38 } 39</script>