Hey I am trying to copy the game that is displayed into the canvas in HTML. I know the canvas is displyed using WebGL so i thought using copyTexImage2D or toDataURL but neither seemed to work. This is how im am using the copyTexImage2D :
var canvas2 = document.createElement('canvas');
var context2 = canvas2.getContext("experimental-webgl"{preserveDrawingBuffer: true});
var gl = document.getElementById("canvas").getContext("experimental-webgl",{preserveDrawingBuffer: true});
var frameBufferObject = gl.createFramebuffer();
var image = gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, canvas.width, canvas.height, 0);
context2.bindTexture(context2.TEXTURE_2D, image);
context2.pixelStorei(context2.UNPACK_FLIP_Y_WEBGL, true);
I know that the image variable I create here is undefined if that has anything to do with going wrong.
Thanks for any help that you can provide.