源码:https://gitee.com/codercmd/webgl_study

<script type="shader" id="vertex">
attribute vec4 apos;
void main(){
gl_PointSize = 20.0;
gl_Position = apos;
}
</script>
gl.getAttribLocation(program,'apos')
let apos = gl.getAttribLocation(program,'apos');
let x1 = 0.5;
let x2 = -0.5;
let how = true;
setInterval(()=>{
how = !how;
if(how == true)
{
gl.vertexAttrib1f(apos,x1);
}
else
{
gl.vertexAttrib1f(apos,x2);
}
// 13.设置背景色
gl.clearColor(1.0,0.0,0.0,1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
// 14.绘制
gl.drawArrays(gl.POINTS,0,1);
},1000)
网友评论