点渲染不出来
来源:2-4 绘制一个点
qq_田美玲_0
2024-04-17
为啥点没有渲染呢
let ctx= document.getElementById(‘canvas’)
// let c=ctx.getContext(‘2d’)
// c.fillStyle=’#535BF2’
// c.fillRect(20,20,300,200)
let gl=ctx.getContext(‘webgl’)
//gl.clearColor(r,g,b,a)取值(0-1)
// let newColor=rgbcolor(148,233,251,1.0)
// gl.clearColor(newColor[0],newColor[1],newColor[2],newColor[3])
// gl.clear(gl.COLOR_BUFFER_BIT)
const point=void main(){ gl_Position=vec4(0.0,0.0,0.0,1.0) gl_PointSize=10.0 }
const area=void main(){ gl_FrageColor=vec4(1.0,0.0,0.0,1.0) }
const pointView=gl.createShader(gl.VERTEX_SHADER)
const areaView=gl.createShader(gl.FRAGMENT_SHADER)
gl.shaderSource(pointView,point)
gl.shaderSource(areaView,area)
gl.compileShader(pointView)
gl.compileShader(areaView)
const program=gl.createProgram()
gl.attachShader(program,pointView)
gl.attachShader(program,areaView)
gl.linkProgram(program)
gl.useProgram(program)
//绘制点
gl.drawArrays(gl.POINTS, 0, 1)//1参数绘制的图像是什么2位置3个数
gl.drawArrays(gl.LINES, 1, 2)
1回答
-
yancy
2024-04-21
着色器代码没有分号吗?
00
相似问题