webGL readPixels and FireFox 35

Minichua

I have updated to FireFox35 and the following code is not working anymore:

    var ctx = renderer2.getContext("experimental-webgl",{preserveDrawingBuffer: true}) || renderer2.getContext("webgl",{preserveDrawingBuffer: true});
    renderer2.render(scene2, camera2, renderTarget);
    var arr = new Uint8Array( 4 * 1024 * 1024);
    ctx.readPixels(0, 0, 1024, 1024, ctx.RGBA, ctx.UNSIGNED_BYTE, arr);

Thre returned array is completely black. It work until FireFox 34 to return the webGL canvas snapshot and it is still working in IE and Chrome.

Is there a workaround, or another way to get the pixel data from a webGL canvas?

Minichua

A bug has been opened @Bugzilla. It seems to be a regression.

Example: http://codepen.io/anon/pen/XJMQwV

<!DOCTYPE html>
<html lang="en">
  <head>
    <title> </title>
    <style>
      body {
        background-color: #000;
        color: #000;
        margin: 0px;
        overflow: hidden;
      }
    </style>
  </head>

  <body>
    <script src="https://ajax.googleapis.com/ajax/libs/threejs/r69/three.min.js"></script>
    <script>
var renderer, camera, renderTarget;
var scene, element;
var ambient;

function createPIP(){

}

function init(){
    pip = document.createElement('div');
    pip.id = "divPIP";
    pip.style.width = 512;
    pip.style.height = 512;
    pip.style.position = 'absolute';
    pip.style.backgroundColor = 'black';
    pip.style.borderRadius = "5px";
    pip.style.border = '2px solid white';
    pip.style.padding = "0px 20px";
    pip.style.left = "50px";
    pip.style.top = "25px";
    document.body.appendChild(pip);

    pip2 = document.createElement('div');
    pip2.id = "divpip2";
    pip2.style.width = 512;
    pip2.style.height = 512;
    pip2.style.position = 'absolute';
    pip2.style.backgroundColor = 'black';
    pip2.style.borderRadius = "5px";
    pip2.style.border = '2px solid white';
    pip2.style.padding = "0px 20px";
    pip2.style.left = "650px";
    pip2.style.top = "25px";
    document.body.appendChild(pip2);
    canvaspip2 = document.createElement('canvas');
    canvaspip2.width = 512;
    canvaspip2.height = 512;
    canvaspip2.id = "canvaspip2";
    pip2.appendChild(canvaspip2);

    scene = new THREE.Scene();

    renderer = new THREE.WebGLRenderer();
    renderer.setSize(512, 512);
    pip.appendChild(renderer.domElement);

    renderTarget = new THREE.WebGLRenderTarget( 512, 512 );

    var ambient = new THREE.AmbientLight( 0xffffff ); 
    scene.add( ambient );

    camera = new THREE.OrthographicCamera( -256, 256, 256, -256, 1, 1e6 );
    scene.add(camera);
    camera.position.set(0, 0, 500);

    cube = new THREE.Mesh( new THREE.CubeGeometry( 200, 200, 200 ), new THREE.MeshNormalMaterial() );

    scene.add(cube);
}

function animate() {
    requestAnimationFrame(animate);
    render();
}

function render() {

    var ctx = renderer.getContext("experimental-webgl",{preserveDrawingBuffer: true}) || renderer.getContext("webgl",{preserveDrawingBuffer: true});
    renderer.render(scene, camera, renderTarget);
    var arr = new Uint8Array( 4 * 512 * 512);
    ctx.readPixels(0, 0, 512, 512, ctx.RGBA, ctx.UNSIGNED_BYTE, arr);
    var c=document.getElementById("canvaspip2");
    var ctx=c.getContext("2d");
    var ImgData = ctx.createImageData(512, 512);
    ImgData.data.set( arr, 0, arr.length );

    var c=document.getElementById("canvaspip2");
    var ctx=c.getContext("2d");
    ctx.putImageData(ImgData,0,0);

    renderer.autoClear = false;
    renderer.clear();
    renderer.render(scene, camera);
}

window.onload = function() {
  init();
  animate();
}
    </script>
</body>
</html>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Working around WebGL readPixels being slow

From Dev

Webgl readPixels() invalid operation: invalid format/type combination

From Dev

Is there a nuked FireFox 35 installation?

From Dev

webGL is not working in Chromium, but it is in Firefox

From Dev

WebGL with Firefox And Chrome

From Dev

WebGL VBO error in Firefox

From Dev

WebGL not rendering in Firefox

From Dev

How to enable WebGL in Chrome or Firefox?

From Dev

Using Firefox 35 with protractor results into an error

From Dev

webgl lighting shader working with firefox but not with chrome

From Dev

Can I programmatically enable WebGL antialiasing on Firefox?

From Dev

WebGL stencil buffer is working only in Firefox

From Dev

webgl lighting shader working with firefox but not with chrome

From Dev

svg-insertAdjacentHTML is not working on firefox version 35 and below?

From Dev

OpenGL ReadPixels (Screenshot) Alpha

From Dev

OpenGL ReadPixels (Screenshot) Alpha

From Dev

Add a CSS class name to HTML tag for Firefox versions less than 35

From Dev

How can the Firefox 35 search option for a match to be case sensitive be set to global?

From Dev

YouTube doesn't play videos using HTML5 in Firefox 35 anymore

From Dev

MacBook Pro running FireFox 35, cannot update to 37.0.2 as update fails silently

From Dev

How to check that firefox switches from integrated to dedicated graphic card in html5 or WebGL (when needed)?

From Dev

Unity: Texture2D ReadPixels for specific Display

From Dev

OpenGL ES ReadPixels to bitmap From Texture larger than screen

From Dev

Unity: Texture2D ReadPixels for specific Display

From Dev

WebGL in wxWebView

From Dev

Python socket error no 35

From Dev

FedEx 35 character limitation

From Dev

FedEx 35 character limitation

From Dev

Project Euler number 35

Related Related

  1. 1

    Working around WebGL readPixels being slow

  2. 2

    Webgl readPixels() invalid operation: invalid format/type combination

  3. 3

    Is there a nuked FireFox 35 installation?

  4. 4

    webGL is not working in Chromium, but it is in Firefox

  5. 5

    WebGL with Firefox And Chrome

  6. 6

    WebGL VBO error in Firefox

  7. 7

    WebGL not rendering in Firefox

  8. 8

    How to enable WebGL in Chrome or Firefox?

  9. 9

    Using Firefox 35 with protractor results into an error

  10. 10

    webgl lighting shader working with firefox but not with chrome

  11. 11

    Can I programmatically enable WebGL antialiasing on Firefox?

  12. 12

    WebGL stencil buffer is working only in Firefox

  13. 13

    webgl lighting shader working with firefox but not with chrome

  14. 14

    svg-insertAdjacentHTML is not working on firefox version 35 and below?

  15. 15

    OpenGL ReadPixels (Screenshot) Alpha

  16. 16

    OpenGL ReadPixels (Screenshot) Alpha

  17. 17

    Add a CSS class name to HTML tag for Firefox versions less than 35

  18. 18

    How can the Firefox 35 search option for a match to be case sensitive be set to global?

  19. 19

    YouTube doesn't play videos using HTML5 in Firefox 35 anymore

  20. 20

    MacBook Pro running FireFox 35, cannot update to 37.0.2 as update fails silently

  21. 21

    How to check that firefox switches from integrated to dedicated graphic card in html5 or WebGL (when needed)?

  22. 22

    Unity: Texture2D ReadPixels for specific Display

  23. 23

    OpenGL ES ReadPixels to bitmap From Texture larger than screen

  24. 24

    Unity: Texture2D ReadPixels for specific Display

  25. 25

    WebGL in wxWebView

  26. 26

    Python socket error no 35

  27. 27

    FedEx 35 character limitation

  28. 28

    FedEx 35 character limitation

  29. 29

    Project Euler number 35

HotTag

Archive