如何使用gl.lineWidth() [英] How to use gl.lineWidth()

查看:247
本文介绍了如何使用gl.lineWidth()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其他所有功能均正常运行,并且正在绘制线条.似乎只是忽略了gl.lineWidth()调用.我还有什么需要做的吗?

Everything else is working smoothly, and the lines are being drawn. It just seems to be ignoring the gl.lineWidth() call. Is there anything else I need to do?

    gl.lineWidth(17);
    gl.drawArrays(this.drawMode,0,totalVertices);

我是否有可能简化事情?可能需要知道我要为哪条线指定宽度吗?

Is there any chance I'm over simplifying things? Could it perhaps need to know which line I'm specifying the width for?

推荐答案

请务必注意,根据WebGL规范,不能保证使用除1.0以外的任何宽度的gl.lineWidth. WebGL基于OpenGL ES 2.0(WebGL2基于OpenGL ES 3.0). OpenGL ES 3.0规范

It's important to note that using gl.lineWidth with any width other than 1.0 is not guaranteed to work according to the WebGL spec. WebGL is based on OpenGL ES 2.0 (WebGL2 is based on OpenGL ES 3.0). The OpenGL ES 3.0 spec says

3.5节

支持的最大线宽必须至少为一.

The maximum line width supported must be at least one.

或者换句话说,不需要支持宽度> 1.0. OpenGL ES 2.0/WebGL1也是这样

Or to put that another way, supporting widths > 1.0 is not required. The same is true for OpenGL ES 2.0 / WebGL1

要找出某行支持的最小和最大宽度,您应该调用gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE),它返回一个由2个数字组成的数组.第一个数字是支持的最小宽度,第二个数字是支持的最大宽度.两者都可以设为1.0

To find out the minimum and maximum width supported for a line you're supposed to call gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE) which returns an array of 2 numbers. The first number is the minimum width supported, the second number is the maximum width supported. Both allowed to be 1.0

因此,您实际上不应该使用gl.lineWidth,因为您的用户可能无法获得除1.0以外的任何宽度.

So, you really shouldn't use gl.lineWidth since you're users may not get any width other than 1.0.

也就是说,一段时间以来,某些实现支持线宽> 1.0. WebGL2于2017年1月发布时,情况发生了很大变化.至少在Mac和Linux上,WebGL2是在OpenGL 3.3的核心配置文件之上实现的.摘录自 OpenGL规范核心配置文件规范附录E

That said, for a while some implementations supported a line width > 1.0. That mostly changed in January 2017 when WebGL2 shipped. WebGL2, at least on Mac and Linux is implemented on top of OpenGL 3.3's core profile. From the OpenGL Spec Core Profile spec appendix E

E.2.1已过时但仍受支持的功能

不推荐使用以下功能,但仍在核心配置文件中提供. 他们 可能会从OpenGL的未来版本中删除,,并且在前向兼容中删除 实施核心配置文件的上下文.

E.2.1 Deprecated But Still Supported Features

The following features are deprecated, but still present in the core profile. They may be removed from a future version of OpenGL, and are removed in a forwardcompatible context implementing the core profile.

  • 宽线-LineWidth值大于1.0会产生INVALID_VALUE错误.

浏览器不会从OpenGL规范中产生错误,因为OpenGL ES规范不需要任何错误,但是由于下面的驱动程序不支持该限制,因此限制仍然存在.

The browsers don't generate the error from the OpenGL spec since the OpenGL ES spec requires no error but the limit is still there because the driver underneath doesn't support them.

如果要绘制大于1的线,则需要自己对线进行栅格化.

If you want to draw lines larger than 1 you need to rasterize the lines yourself.

这篇关于如何使用gl.lineWidth()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆