Gagiopapinni Posted July 5, 2018 Share Posted July 5, 2018 Could you please explain me the difference between rendering through renderCanvas() and through renderer.render() There is nothing about specific differences on the doc's page , so it seemed they must work in the same way , but in fact they does not for example ... var r = new PIXI.CanvasRenderer( {width:600,height:800,backgroundColor: 0x1099bb,}); document.body.appendChild(r.view); var richText = new PIXI.Text('Rich text with a lot of options and across multiple lines'); richText.x = 30; richText.y = 180; //r.render(richText); // - working as expected, the text stands at 30,180 richText.renderCanvas(r) // -- not really the same, the text stands at 0,0 after this I started wondering , maybe it works in this way because the text has no parent object ... ( because as said in the docs the X and Y are relative coordinates to the parent ) and then I tryed this : var r = new PIXI.CanvasRenderer( {width:600,height:800,backgroundColor: 0x1099bb,}); document.body.appendChild(r.view); var richText = new PIXI.Text('Rich text with a lot of options and across multiple lines'); richText.x = 30; richText.y = 180; var stage = new PIXI.Container(); stage.addChild(richText); //r.render(stage); // - working as expected, the text stands at 30,180 stage.renderCanvas(r) // again, the text stands at 0,0 the result is the same , nothing works as expected Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 5, 2018 Share Posted July 5, 2018 `updateTransform` is the difference. Stop treating pixi like a black box. There are many operations in `render`, not only call of `renderCanvas`: https://github.com/pixijs/pixi.js/blob/dev/src/core/renderers/canvas/CanvasRenderer.js#L133 , https://github.com/pixijs/pixi.js/blob/dev/src/core/renderers/canvas/CanvasRenderer.js#L236 and even more if you use WebGLRenderer. Also, there might be bugs, waiting for a hero to fix them Quote Link to comment Share on other sites More sharing options...
Gagiopapinni Posted July 5, 2018 Author Share Posted July 5, 2018 6 hours ago, ivan.popelyshev said: `updateTransform` is the difference. Stop treating pixi like a black box. There are many operations in `render`, not only call of `renderCanvas`: https://github.com/pixijs/pixi.js/blob/dev/src/core/renderers/canvas/CanvasRenderer.js#L133 , https://github.com/pixijs/pixi.js/blob/dev/src/core/renderers/canvas/CanvasRenderer.js#L236 and even more if you use WebGLRenderer. Also, there might be bugs, waiting for a hero to fix them Alright, it works with updateTransform ... BUT ! If there is a bug and in reality it is supposed to be the same as the renderer.render() function , then why did they call it renderCanvas()/renderWebGL() ??? why not just DisplayObject.render() ? And on the other hand, if there is no bug and this extremely specific behaviour is what they wanted to make , in that case how would the extra 'Canvas' word indicate about such a specific difference ?(because they are not telling about it in the docs ) !! Isn't it ? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 5, 2018 Share Posted July 5, 2018 Originally there was also an object "renderSession" that was created inside the renderer for this particular frame, and passed in those functions, so it wasn't possible to just call it from outside because there was no renderSession. They got rid of it in favor of having state inside render managers (like filterManager) before I joined pixi dev team, that's why in v3 and v4 its possible to call renderXXX with correct parameters and get strange results 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.