【发布时间】:2015-06-07 08:14:16
【问题描述】:
所以我有这个 WebGL 顶点着色器:
precision mediump float;
uniform mat4 camera;
uniform vec3 pos0;
uniform float time;
attribute float t0;
attribute vec3 dir0;
void main() {
float t = time - t0;
gl_Position = camera * vec4(dir0, 1);
gl_PointSize = 10.0;
}
效果很好,但如果我只更改以下行
gl_Position = camera * vec4(pos0 + dir0 * t, 1);
Firefox 抱怨:
Error: WebGL: drawElements: no VBO bound to enabled vertex attrib index 0!
如果我将同一行更改为以下内容:
gl_Position = camera * vec4(pos0, 1);
错误不同:
Error: WebGL: Drawing without vertex attrib 0 array enabled forces the browser to do expensive emulation work when running on desktop OpenGL platforms, for example on Mac. It is preferable to always draw with vertex attrib 0 array enabled, by using bindAttribLocation to bind some always-used attribute to location 0.
Error: WebGL: Integer overflow trying to construct a fake vertex attrib 0 array for a draw-operation with -1 vertices. Try reducing the number of vertices.
发生了什么事?
编辑:Chromium 给出了更清晰的错误信息:
glDrawElements: attempt to access out of range vertices in attribute 1
【问题讨论】:
-
你是如何设置你的制服和属性的?你能发布你的代码吗?
标签: glsl webgl vertex-shader