首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WebGl LINE_STRIP宽度

WebGl LINE_STRIP宽度
EN

Stack Overflow用户
提问于 2015-01-18 12:37:36
回答 1查看 5.2K关注 0票数 0

我正在画一个充满顶点的vbo,它看起来如下: x,y,r,g,b,.使用呈现模式: LINE_STRIP。

我使用以下函数向vbo添加了一个值:

代码语言:javascript
复制
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();

然后我这样称呼它:

代码语言:javascript
复制
this.addBufferValue({x: x, y: y, r: 1, g: 1, b: 1});

这是我的渲染代码:

代码语言:javascript
复制
  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中实现这一效果?如果是的话,我将如何实现。如果没有,还有其他方法来实现我的目标吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-20 13:12:41

目前,windows浏览器只支持线宽1 1px (由于使用了DirectX角层)。如您所见- http://alteredqualia.com/tmp/webgl-linewidth-test/ (在Chrome、ie和火狐中尝试过)

你要做的是通过创建三角形来模拟你的线宽。

这需要在着色器中做更多的工作,并添加额外的顶点和属性。

后面的主要思想是根据线的角度添加两个不同属性偏移量的顶点,并在阴影中相应地偏移顶点(当然要考虑分辨率)。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28009734

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档