This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <canvas width="512" height="512"></canvas><hr/> | |
| <textarea id="LOG" cols="30" rows="10" value=""></textarea> | |
| <script>"use strict"; | |
| let opt={preserveDrawingBuffer:true} | |
| let cx=document.querySelector("canvas").getContext("webgl",opt); | |
| cx.clearColor(0,0,0,1);cx.clear(0x4000); | |
| cx.canvas.addEventListener("touchstart",hander,false); | |
| cx.canvas.addEventListener("touchmove",hander,false); | |
| function hander(e){ | |
| e.preventDefault(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style>textarea{background-color: burlywood;}</style> | |
| <canvas width="384" height="256"></canvas><hr/> | |
| <textarea id="LOG" cols="48" rows="14"></textarea> | |
| <script>"use strict"; | |
| const vsrc=`attribute vec4 p;uniform mat4 m; | |
| void main(){ | |
| gl_Position=p*m;gl_Position.w=1.+gl_Position.z*.5; | |
| gl_PointSize=6./gl_Position.w; | |
| }`; | |
| const fsrc=`precision highp float; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <canvas width="256" height="256"></canvas><hr/> | |
| <textarea id="LG" cols="30" rows="10"></textarea> | |
| <script>"use strict"; | |
| const vsrc=`attribute vec4 p;uniform float tm;varying vec2 co; | |
| mat4 m=mat4(cos(tm),0,sin(tm),0,0,1,0,0,-sin(tm),0,cos(tm),0,0,0,0,1); | |
| void main(){ | |
| gl_Position=vec4(2.*p.xy-1.,0,1)*m; | |
| gl_Position.w=1./(1.+(gl_Position.z*0.2)); co=p.xy; | |
| }`; | |
| const fsrc=`precision highp float;uniform sampler2D tx;varying vec2 co; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <canvas width="256" height="256"></canvas><hr/> | |
| <input type="text"> | |
| <script>"use strict"; | |
| let vsrc=`uniform vec2 m;varying vec2 vm; | |
| void main(){vm=m;gl_PointSize=4.;gl_Position=vec4(m,0,1);}`; | |
| let fsrc=`precision highp float;varying vec2 vm; | |
| void main(){gl_FragColor=vec4(vm/2.+1.,0,1);}`; | |
| let opt={preserveDrawingBuffer:true}; | |
| let cx=document.querySelector("canvas").getContext("webgl",opt); | |
| let LG=document.querySelector("input"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <canvas width="200" height="200"></canvas><hr/> | |
| <script>"use strict"; | |
| let VIEWPORT; | |
| let opt={preserveDrawingBuffer:true}; | |
| let cx=document.querySelector("canvas").getContext("webgl",opt); | |
| viewport([0,0,cx.canvas.clientWidth,cx.canvas.clientHeight]); | |
| let cube=[1,1,1, 1,-1,1], stride=3; | |
| function draw(now){ | |
| let time=now/1000; | |
| cx.clearColor(0,.2,0,1);cx.disable(cx.SCISSOR_TEST);cx.clear(0x4000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <canvas width="512" height="512"></canvas> | |
| <script>"use strict"; | |
| let opt={preserveDrawingBuffer:true} | |
| let cx=document.querySelector("canvas").getContext("webgl",opt); | |
| function draw(now){ | |
| let x,y,z, sec=now/1000; | |
| cx.disable(cx.SCISSOR_TEST); | |
| cx.clearColor(0,0,.6,1); cx.clear(0x4000); | |
| cx.enable(cx.SCISSOR_TEST); | |
| for(let i=0;i<100000; i++){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <canvas width="512" height="512"></canvas><hr/> | |
| rotX:<input id="ROTX" type="range" value="50"><hr/> | |
| <textarea id="LOG" cols="40" rows="15"></textarea> | |
| <script>"use strict"; | |
| let cx=document.querySelector("canvas").getContext("webgl"); | |
| let pg=cx.createProgram(); | |
| let vs=cx.createShader(cx.VERTEX_SHADER); cx.attachShader(pg,vs); | |
| let fs=cx.createShader(cx.FRAGMENT_SHADER); cx.attachShader(pg,fs); | |
| let vsrc=`attribute vec4 p;uniform mat4 m;uniform sampler2D tx;uniform vec2 u; | |
| varying vec4 c;void main(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style>canvas,textarea{background-color: khaki;}</style> | |
| <canvas width="256" height="256"></canvas><hr/> | |
| <textarea id="LOG" cols="40" rows="20"></textarea> | |
| <script>"use strict"; | |
| let cx=document.querySelector("canvas").getContext("webgl"); | |
| let pg=cx.createProgram(); | |
| let vs=cx.createShader(cx.VERTEX_SHADER);cx.attachShader(pg,vs); | |
| let fs=cx.createShader(cx.FRAGMENT_SHADER);cx.attachShader(pg,fs); | |
| let vsrc=`attribute vec4 p;uniform mat4 m;varying vec4 c; | |
| void main(){gl_Position=p*m;gl_Position.xyz/=2.+.5*gl_Position.z; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style>canvas{background-color: khaki;}</style> | |
| <canvas width="256" height="256"></canvas><hr> | |
| <textarea id="LOG" cols="32" rows="12"></textarea> | |
| <script>"use strict"; | |
| let cx=document.querySelector("canvas").getContext("webgl"); | |
| let pg=cx.createProgram(); | |
| let vs=cx.createShader(cx.VERTEX_SHADER); cx.attachShader(pg,vs); | |
| let fs=cx.createShader(cx.FRAGMENT_SHADER); cx.attachShader(pg,fs); | |
| let vsrc=`attribute vec4 p;uniform sampler2D tx;uniform mat4 m;varying vec3 vc; | |
| mat4 n=mat4(1,0,0,0, 0,1,0,-1, 0,0,1,0, 0,0,1,2);void main(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style>canvas,textarea{background-color: khaki;}</style> | |
| <canvas width="512" height="512"></canvas><hr/> | |
| <textarea id="LOG" cols="32" rows="15"></textarea> | |
| <script>"use strict"; | |
| let cx=document.querySelector("canvas").getContext("webgl"); | |
| const AB=cx.ARRAY_BUFFER,EB=cx.ELEMENT_ARRAY_BUFFER; | |
| let pg=cx.createProgram(); | |
| let vs=cx.createShader(cx.VERTEX_SHADER); cx.attachShader(pg,vs); | |
| let fs=cx.createShader(cx.FRAGMENT_SHADER); cx.attachShader(pg,fs); | |
| let vsrc=`attribute vec4 p,q;uniform mat4 m,o;varying vec4 vc; |