Leth Posted April 14, 2014 Share Posted April 14, 2014 Hi, I'm trying to get the dataURL of a RenderTexture using the WebGL renderer.With the Canvas renderer, it's easy: // ...var renderer = new PIXI.CanvasRenderer(width, height);// ...var canvasDataURL = renderer.view.toDataURL();var renderTexture = new PIXI.RenderTexture(42, 42);renderTexture.render(someDoc);var renderTextureDataURL = renderTexture.baseTexture.source.toDataURL();But with WebGL I can't find how to do it. The baseTexture of a RenderTexture have an undefined source.Also, with WebGL, if I want to be able to get the dataURL of the view/canvas, I have to modify the source of pixi to add the option preserveDrawingBuffer to the context here: https://github.com/GoodBoyDigital/pixi.js/blob/master/src/pixi/renderers/webgl/WebGLRenderer.js#L72 this.options = { alpha: this.transparent, antialias:!!antialias, // SPEED UP?? premultipliedAlpha:!!transparent, stencil:true, preserveDrawingBuffer: true,}; My questions:1. Is it possible to set preserveDrawingBuffer somewhere without modifing pixi's source ?2. How to get the dataURL of a RenderTexture like in the first example, but for WebGL ? (When preserveDrawingBuffer is true)3. Where does pixi issues drawing commands to WebGL context ? I'v read this ( http://stackoverflow.com/a/12548710 ) and I'm trying to find where/when should I get the dataURL of an element in the source without setting preserveDrawingBuffer to true. By the way, I really love Pixi.js. A big thanks to all the contributors ! Quote Link to comment Share on other sites More sharing options...
Sebi Posted April 16, 2014 Share Posted April 16, 2014 No clue how it works with WebGL.But I had the same issue when I was creating my PixiTexturePacker. At some point I was just like..screw this...if(renderer instanceof PIXI.CanvasRenderer) { canvasRenderer = renderer;} else { canvasRenderer = new PIXI.CanvasRenderer(width, height, null, true);}...var renderTexture = new PIXI.RenderTexture(width, height, canvasRenderer);...So I just always created a canvas renderer instance. That way I had access to the renderTexture.baseTexture.source which I could draw on a canvas and then export the dataurl. Not like it makes a huge difference. Leth 1 Quote Link to comment Share on other sites More sharing options...
Leth Posted April 16, 2014 Author Share Posted April 16, 2014 I did not realize I could do this Thanks a lot ! Quote Link to comment Share on other sites More sharing options...
Sebi Posted April 17, 2014 Share Posted April 17, 2014 There is probably a way to do this with the WebGL renderer though.Gotta wait for the WebGL profis to tell us their secrets, haha 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.