joshcamas Posted October 14, 2016 Share Posted October 14, 2016 Hi guys! I'm looking at the BABYLON.Tools.CreateScreenshot() function, and I'm trying to use bits of that code to create an image (encoded in base64) from the babylon canvas. I do this: this.canvas = document.createElement('canvas'); this.canvas.width = Game.canvas.width; this.canvas.height = Game.canvas.height; this.ctx = this.canvas.getContext("2d"); this.ctx.drawImage(Game.engine.getRenderingCanvas(), 0, 0, Game.canvas.width, Game.canvas.height); console.log(this.ctx.getImageData(0, 0, Game.canvas.width, Game.canvas.height)); $("#render").attr('src', this.canvas.toDataURL("image/png")) And all it does is create an empty image, and the data is just an array full of 0's! AHHHHHH Why is this? Quote Link to comment Share on other sites More sharing options...
joshcamas Posted October 15, 2016 Author Share Posted October 15, 2016 Ahhhhhhhgggg today's my one day off I can't get this working, which is the main point of the program! ;_; Basically, I want to rebuild the screenshot tool, but it seems not to work. How can I hijack it without it saving the image? EDIT: Ok, at last I figured it out. I simply copied the functions BABYLON.Tools.DumpFramebuffer() and BABYLON.Tools.CreateScreenshot (which for some reason is "CreateScreenshotUsingRenderTarget" in github, hence all the confusion) and renamed them to my liking. VERY UGLY, but it works Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted October 15, 2016 Share Posted October 15, 2016 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.