Andles Posted May 9, 2015 Share Posted May 9, 2015 In WebGL mode, is it possible to capture the current game screen (screen shot)? So, for example, one could upload it to facebook or use it in a 'game over' effect? I could do this in Canvas mode, but not in WebGL. Thanks in advanceAndy PAINKILLER 1 Link to comment Share on other sites More sharing options...
igin Posted May 9, 2015 Share Posted May 9, 2015 use webglContext.readPixels() methodif(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 More sharing options...
kiwi Posted November 19, 2015 Share Posted November 19, 2015 use webglContext.readPixels() methodif(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 More sharing options...
greatimposter Posted January 19, 2016 Share Posted January 19, 2016 Not sure if this will help you, but there's an answer along the lines of this question at SO: http://stackoverflow.com/questions/9267899/arraybuffer-to-base64-encoded-string let me know if that helps! Link to comment Share on other sites More sharing options...
Recommended Posts