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

Feature Chrome Edge Firefox Internet Explorer Opera Safari Servo
Basic SupportNo supportNo supportNo supportNo supportNo supportNo supportNo support
Feature Android Chrome for Android Edge Mobile Firefox for Android IE Mobile Opera Mobile Safari Mobile
Basic SupportNo supportNo supportNo supportNo supportNo supportNo supportNo support

See also

Document Tags and Contributors

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