Jump to content

Phaser Screenshot - WEBGL Issue


JesusJoseph
 Share

Recommended Posts

Hi,

Thanks for reading.

In my phaser game I need to share the screenshot of the game. Its working perfectly in CANVAS mode but its not working in WEBGL mode.

I use the below code to get the screenshot and convert to base64 image.

var gl = SequentialTap.game.renderer.gl;
var buf = new Uint8Array(SequentialTap.game.width * SequentialTap.game.height * 4);
gl.readPixels(0, 0, SequentialTap.game.width, SequentialTap.game.height, gl.RGBA, gl.UNSIGNED_BYTE, buf);

// Covert Buffer Array to Base64 Image
var binary = '';
var bytes = new Uint8Array(buf);
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
	binary += String.fromCharCode(bytes[i]);
}
base64Image = window.btoa(binary);

But the output (base64Image in below code) is generated as below. But this value is not the base64 image format

AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAA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ue with the WEBGL mode.

 

Thanks for your help.

 

Thanks

Joseph

Edited by JesusJoseph
Link to comment
Share on other sites

Hi All,

I try to use html2canvas to get create the screenshot. But working correctly in Chrome or IE  but its not working in andorid tablet.

This is the code that I use to get the screenshot, which is still producing blank image

html2canvas(document.querySelector("canvas"), {
            onrendered: function(canvas) {
                base64Image = canvas.toDataURL();
                document.getElementById("content").innerHTML = base64Image;
                shareScreenshot(base64Image, callback);
            }
        });

Any help will be highly appricated.

 

thanks

Joseph

Link to comment
Share on other sites

  • 2 weeks later...
 Share

  • Recently Browsing   0 members

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