diff --git a/examples/context_assignment_test.html b/examples/context_assignment_test.html new file mode 100644 index 0000000000000000000000000000000000000000..7fcd0927c425bf236d09eaa57a66279b3810b8a7 --- /dev/null +++ b/examples/context_assignment_test.html @@ -0,0 +1,73 @@ + + + Pre-created Context Assignment Test + + + + + + + + + +
+This test checks if Three.js successfully used the pre-created GL context passed from framework outside of Three.js.
For more information refer to this issue list in Three.js github
The screen should show 2 square boxes of size 256x256, one filled by CSS in green color, and the other filled by WebGL in red color. If the red box is shown and same in size to the green box, it indicates that the test is successful. +
+ +
+The above is the CSS filled box, not GL, in Green color. +

+The below is the GL filled box, not CSS, in Red color. +
+ + +
+
+Prabindh Sundareson + + + diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 505b5b2d91493d019bdf93ae61b59c2c16558d9b..4793eed49ad0ae7748b1dca8334f7db91fcffb2f 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -12,6 +12,7 @@ THREE.WebGLRenderer = function ( parameters ) { parameters = parameters || {}; var _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElement( 'canvas' ), + _givenGLContext = parameters.givenGLContext !== undefined ? parameters.givenGLContext : null, _precision = parameters.precision !== undefined ? parameters.precision : 'highp', @@ -6517,7 +6518,7 @@ THREE.WebGLRenderer = function ( parameters ) { preserveDrawingBuffer: _preserveDrawingBuffer }; - _gl = _canvas.getContext( 'webgl', attributes ) || _canvas.getContext( 'experimental-webgl', attributes ); + _gl = _givenGLContext || _canvas.getContext( 'webgl', attributes ) || _canvas.getContext( 'experimental-webgl', attributes ); if ( _gl === null ) {