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 id="CNVS" width="512px" height="512px"></canvas> | |
| <script> | |
| const vsrc="attribute vec4 p;void main(){gl_Position=vec4(p.xy*.9,0.,1.);}"; | |
| const fsrc="void main(){gl_FragColor=vec4(1);}"; | |
| const gl=document.getElementById("CNVS").getContext("webgl"); | |
| enableStaticAttr2f(gl,0, new Float32Array([-1,-1,-1,1,1,-1,1,1])); | |
| var prg,vs,fs; | |
| vs=gl.createShader(gl.VERTEX_SHADER); setSource(vs,vsrc); log(compile(vs)); | |
| fs=gl.createShader(gl.FRAGMENT_SHADER); setSource(fs,fsrc); log(compile(fs)); | |
| prg=gl.createProgram(); attach(prg,vs); attach(prg,fs); log(link(prg)); |
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
| <div id="GamePadUI"> | |
| buttons<input id="b" type="text"><br/> | |
| axis0<input id="a0" type="range"><br/> | |
| axis1<input id="a1" type="range"><br/> | |
| axis2<input id="a2" type="range"><br/> | |
| axis3<input id="a3" type="range"><br/> | |
| </div> | |
| <script> | |
| UI={};UI.a=[]; | |
| UI.b=document.getElementById("b"); |
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 id="canvas" width="500" height="500"></canvas> | |
| <script> | |
| const vssrc=`attribute vec4 position;varying vec4 vcolor; | |
| void main(void){ | |
| vec3 eye=vec3(0,0,-1.5); // 目はここに置く! | |
| float l=distance(eye.xyz, position.xyz); // 「遠く」…それは… | |
| gl_PointSize=(1.0/l)*32.; // 遠いほど | |
| gl_Position.xy=position.xy*(1.0/l); // 小さい! | |
| gl_Position.z=position.z; | |
| gl_Position.w=1.0; |
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 id="CNVS" width="300" height="300"></canvas> | |
| <script> | |
| const vsrc1=`attribute vec4 aPosi;uniform mat4 uMvpm; | |
| void main(void){gl_Position=aPosi*uMvpm;}`; | |
| const fsrc1=`void main(void){gl_FragColor=vec4(1);}`; | |
| var gl=CNVS.getContext("webgl"); | |
| var pg0=getp(gl, vsrc1, fsrc1); | |
| const data=new Float32Array([0,1, 1,0, -1,0]); | |
| var bf0=gl.createBuffer(); | |
| gl.bindBuffer(gl.ARRAY_BUFFER, bf0);{ |
NewerOlder