WebGLRenderingContext.lineWidth()

The WebGLRenderingContext.lineWidth() method of the WebGL API sets the line width of rasterized lines.

gl.lineWidth() has no effect in common modern browsers. The corresponding Chromium bug and Firefox bug are closed as Won't Fix and the WebGL specification now defines that gl.lineWidth() does not change the line width anymore. If you need lines of any width other than 1px, consider drawing a narrow strip of triangles.

Syntax

void gl.lineWidth(width);

Parameters

width
A GLfloat specifying the width of rasterized lines. Default value: 1.

Return value

None.

Examples

Setting the line width:

gl.lineWidth(5);

Getting the line width:

gl.getParameter(gl.LINE_WIDTH);

Getting the range of available widths. Returns a Float32Array.

gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE);

Specifications

Specification Status Comment
WebGL 1.0
The definition of 'lineWidth' in that specification.
Recommendation Initial definition.
OpenGL ES 2.0
The definition of 'glLineWidth' in that specification.
Standard Man page of the OpenGL API.

Browser compatibility

FeatureChromeFirefoxEdgeInternet ExplorerOperaSafari
Basic Support(No)(No)(No)(No)(No)(No)
FeatureAndroidChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic Support(No)(No)(No)(No)(No)(No)(No)

See also

Document Tags and Contributors

 Contributors to this page: fscholz, dcposch, teoli
 Last updated by: fscholz,