Add “How to use WebGL 2.0” section in Document

Description of the problem

I think we need “How to use WebGL 2.0” section in the document. Probably what we need in the section are

How to detect WebGL 2.0 availability.

if ( WEBGL.isWebGL2Available() === false ) {

    document.body.appendChild( WEBGL.getWebGL2ErrorMessage() );

}

How to use WebGL 2.0 renderer.

var canvas = document.createElement( 'canvas' );
var context = canvas.getContext( 'webgl2' );
var renderer = new THREE.WebGLRenderer( { canvas: canvas, context: context } );

How to write GLSL ES3.0 with [Raw]ShaderMaterial.

<script id="vs" type="x-shader/x-vertex">
#version 300 es

void main() {

    gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

}
</script>
<script id="fs" type="x-shader/x-fragment">
#version 300 es

precision highp float;
precision highp int;
out vec4 out_FragColor;

void main() {

    out_FragColor = vec4( 1.0 );

}
</script>

var material = new THREE.ShaderMaterial( {
    vertexShader: document.getElementById( 'vs' ).textContent.trim(),
    fragmentShader: document.getElementById( 'fs' ).textContent.trim()
} );

And the links to WebGL 2.0 examples. (And, WebGL 2.0 features we’re supporting right now?)

Three.js version
  • Dev
  • r97
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

1 thought on “Add “How to use WebGL 2.0” section in Document

  1. You can use a WebGL 2 rendering context since R95. But not all WebGL 2 feature are implemented yet.

Comments are closed.