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
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Feature | Chrome | Firefox | Edge | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic Support | (No) | (No) | (No) | (No) | (No) | (No) |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support | (No) | (No) | (No) | (No) | (No) | (No) | (No) |