W3cubDocs

/DOM

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 Support No support No support No support No support No support No support No support
Feature Android Chrome for Android Edge Mobile Firefox for Android IE Mobile Opera Mobile Safari Mobile
Basic Support No support No support No support No support No support No support No support

See also

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/lineWidth