首页 > 其他分享 >fp webgl

fp webgl

时间:2022-11-14 09:26:11浏览次数:34  
标签:fp uniformOffset webgl attrVertex vec2 var varyinTexCoordinate

 

 

var e = document.createElement('canvas');
var t = e.getContext('webgl');
var r = [];
var o = t.createBuffer();
t.bindBuffer(34962, o);
var i = new Float32Array([-.2, -.9, 0, .4, -.26, 0, 0, .732134444, 0]);
t.bufferData(34962, i, 35044);
o.itemSize = 3;
o.numItems = 3;
var s = t.createProgram();
var a = t.createShader(35633);
t.shaderSource(a, 'attribute vec2 attrVertex;varying vec2 varyinTexCoordinate;uniform vec2 uniformOffset;void main(){varyinTexCoordinate=attrVertex+uniformOffset;gl_Position=vec4(attrVertex,0,1);}');
t.compileShader(a);
var c = t.createShader(35632);
t.shaderSource(c, 'precision mediump float;varying vec2 varyinTexCoordinate;void main() {gl_FragColor=vec4(varyinTexCoordinate,0,1);}');

t.compileShader(c);
t.attachShader(s, a);
t.attachShader(s, c);
t.linkProgram(s);
t.useProgram(s);
s.vertextPosAttrib = t.getAttribLocation(s, 'attrVertex');
s.offsetUniform = t.getUniformLocation(s, 'uniformOffset');

t.enableVertexAttribArray(s.vertexPosArray);
t.vertexAttribPointer(s.vertexPosAttrib, o.itemSize, t.FLOAT, !1, 0, 0);
t.uniform2f(s.offsetUniform, 1, 1);
t.drawArrays(t.TRIANGLE_STRIP, 0, o.numItems);

r.push(t.canvas.toDataURL());
r.push('extensions:'+t.getSupportedExtensions().join(';'));

console.log(r);

 

标签:fp,uniformOffset,webgl,attrVertex,vec2,var,varyinTexCoordinate
From: https://www.cnblogs.com/angdh/p/16887978.html

相关文章