02.顶点变量赋值

2020-03-15  本文已影响0人  cmd_ts

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

22.gif
 <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)
上一篇 下一篇

猜你喜欢

热点阅读