我正在画一个充满顶点的vbo,它看起来如下: x,y,r,g,b,.使用呈现模式: LINE_STRIP。
我使用以下函数向vbo添加了一个值:
this.gameBuffer.vertices[this.gameBuffer.vertices.count * this.gameBuffer.vertices.step + 0] = circle.x;
this.gameBuffer.vertices[this.gameBuffer.vertices.count * this.gameBuffer.vertices.step + 1] = circle.y;
this.gameBuffer.vertices[this.gameBuffer.vertices.count * this.gameBuffer.vertices.step + 2] = circle.r;
this.gameBuffer.vertices[this.gameBuffer.vertices.count * this.gameBuffer.vertices.step + 3] = circle.g;
this.gameBuffer.vertices[this.gameBuffer.vertices.count * this.gameBuffer.vertices.step + 4] = circle.b;
this.gameBuffer.vertices.count++;
this.setFloatValues();然后我这样称呼它:
this.addBufferValue({x: x, y: y, r: 1, g: 1, b: 1});这是我的渲染代码:
this.gl.vertexAttribPointer(this.defaultShader.prog.attribs['vertexPos'], 2, this.gl.FLOAT, false, 20, 0);
this.gl.vertexAttribPointer(this.defaultShader.prog.attribs['acolour'], 3, this.gl.FLOAT, false, 20, 8);
this.drawDynamic(this.gameBuffer, this.gl.LINE_STRIP, this.gameBuffer.vertices.length / this.gameBuffer.vertices.step, 1);
Game.prototype.drawDynamic = function(updatedData, method, count, step) {
this.gl.bufferSubData(this.gl.ARRAY_BUFFER, 0, updatedData.floatVertices);
this.gl.drawArrays(method, 0, count * step);
}然而,我的线的宽度似乎只有1 1px,经过进一步的调查,这似乎是唯一的厚度可用。我的问题是:是否有可能在LINE_STRIP中实现这一效果?如果是的话,我将如何实现。如果没有,还有其他方法来实现我的目标吗?
发布于 2015-01-20 13:12:41
目前,windows浏览器只支持线宽1 1px (由于使用了DirectX角层)。如您所见- http://alteredqualia.com/tmp/webgl-linewidth-test/ (在Chrome、ie和火狐中尝试过)
你要做的是通过创建三角形来模拟你的线宽。
这需要在着色器中做更多的工作,并添加额外的顶点和属性。
后面的主要思想是根据线的角度添加两个不同属性偏移量的顶点,并在阴影中相应地偏移顶点(当然要考虑分辨率)。

https://stackoverflow.com/questions/28009734
复制相似问题