Jump to content

screen capture the current game screen


Andles
 Share

Recommended Posts

use webglContext.readPixels() method

if(game.renderer instanceof PIXI.CanvasRenderer){    var url = game.canvas.toDataURL('image/png');    console.log(url);}else if(game.renderer instanceof PIXI.WebGLRenderer){    var gl = game.renderer.gl;    var buf = new Uint8Array(game.width * game.height * 4);    gl.readPixels(0, 0, game.width, game.height, gl.RGBA, gl.UNSIGNED_BYTE, buf);    console.log(buf);}
Link to comment
Share on other sites

  • 6 months later...

 

use webglContext.readPixels() method

if(game.renderer instanceof PIXI.CanvasRenderer){    var url = game.canvas.toDataURL('image/png');    console.log(url);}else if(game.renderer instanceof PIXI.WebGLRenderer){    var gl = game.renderer.gl;    var buf = new Uint8Array(game.width * game.height * 4);    gl.readPixels(0, 0, game.width, game.height, gl.RGBA, gl.UNSIGNED_BYTE, buf);    console.log(buf);}

 

I implemented this method but I get an array of bytes. How do I convert to base64?

 

thanks

Link to comment
Share on other sites

  • 1 month later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...