12.【WebGL错误-1】INVALID_VALUE: vertexAttribPointer: index out of range

WebGL: INVALID_VALUE: vertexAttribPointer: index out of range

错误:gl.getAttribLocation(shaderProgram, ‘aVertexPosition’) 变量取不到值.
原因&解决:变量名称对不上,仔细检查定义的变量名

// gl.vertexAttribPointer参数解释
gl.vertexAttribPointer(index, size, type, normalized, stride, offset);

1)index:A GLuint specifying the index of the vertex attribute that is to be modified.

2)size:A GLint specifying the number of components per vertex attribute. Must be 1, 2, 3, or 4.

3)type:A GLenum specifying the data type of each component in the array. Possible values:
	gl.BYTE: signed 8-bit integer, with values in [-128, 127]
	gl.SHORT: signed 16-bit integer, with values in [-32768, 32767]
	gl.UNSIGNED_BYTE: unsigned 8-bit integer, with values in [0, 255]
	gl.UNSIGNED_SHORT: unsigned 16-bit integer, with values in [0, 65535]
	gl.FLOAT: 32-bit IEEE floating point number
When using a WebGL 2 context, the following values are available additionally:
	gl.HALF_FLOAT: 16-bit IEEE floating point number

4)normalized:A GLboolean specifying whether integer data values should be normalized into a certain range when being casted to a float.
	For types gl.BYTE and gl.SHORT, normalizes the values to [-1, 1] if true.
	For types gl.UNSIGNED_BYTE and gl.UNSIGNED_SHORT, normalizes the values to [0, 1] if true.
	For types gl.FLOAT and gl.HALF_FLOAT, this parameter has no effect.

5)stride:A GLsizei specifying the offset in bytes between the beginning of consecutive vertex attributes. Cannot be larger than 255. If stride is 0, the attribute is assumed to be tightly packed, that is, the attributes are not interleaved but each attribute is in a separate block, and the next vertex' attribute follows immediately after the current vertex.

6)offset:A GLintptr specifying an offset in bytes of the first component in the vertex attribute array. Must be a multiple of the byte length of type.

Return value: None.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值