Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add webgl2 parameter (default:false) to WebGLRenderer parameters. #10782

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/api/renderers/WebGLRenderer.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ <h3>[name]( [page:Object parameters] )</h3>
[page:Boolean preserveDrawingBuffer] - whether to preserve the buffers until manually cleared
or overwritten. Default is *false*.<br />

[page:Boolean webgl2] - whether to request a [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext WebGL2RenderingContext].
Default is *false*.<br />

[page:Boolean depth] - whether the drawing buffer has a
[link:https://en.wikipedia.org/wiki/Z-buffering depth buffer] of at least 16 bits.
Default is *true*.<br />
Expand Down
5 changes: 3 additions & 2 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function WebGLRenderer( parameters ) {

_alpha = parameters.alpha !== undefined ? parameters.alpha : false,
_depth = parameters.depth !== undefined ? parameters.depth : true,
_webgl2 = parameters.webgl2 !== undefined ? parameters.webgl2 : false,
_stencil = parameters.stencil !== undefined ? parameters.stencil : true,
_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,
Expand Down Expand Up @@ -229,11 +230,11 @@ function WebGLRenderer( parameters ) {
preserveDrawingBuffer: _preserveDrawingBuffer
};

_gl = _context || _canvas.getContext( 'webgl', attributes ) || _canvas.getContext( 'experimental-webgl', attributes );
_gl = _context || _canvas.getContext( _webgl2 ? 'webgl2' : 'webgl', attributes ) || _canvas.getContext( 'experimental-webgl', attributes );

if ( _gl === null ) {

if ( _canvas.getContext( 'webgl' ) !== null ) {
if ( _canvas.getContext( _webgl2 ? 'webgl2' : 'webgl' ) !== null ) {

throw 'Error creating WebGL context with your selected attributes.';

Expand Down