Jump to content

Getting pixels from render?


Recommended Posts

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?

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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