seraphpl Posted October 14, 2020 Share Posted October 14, 2020 Hi, is there a low level API to draw on top of what's already rendered like html canvas api? I don't want draw everything again on each frame when there is only little change. Say, we have already drew 100,000 lines a canvas. On next frame, we only need to draw another line of from position 0,0 to position 10,0. We don't want to clear the canvas and draw 100,001 lines again. In html canvas api, we can do something line beginPath + draw line + closePath, then beginPath + draw line + closePath, and then so on... Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 14, 2020 Share Posted October 14, 2020 No, and it doesnt exist for reason - every such operation involves many computations to make those lines, so its better to be cached. If you want to do it each frame, well, just clear() graphics and refill it each time. The downside is that memory for polygon and buffers will be re-allocated each time, but you can try modify it and use "invalidate()" thingy in graphicsGeometry if it becomes a problem. Alternatively, PIXI.Mesh or PIXI.SimpleMesh with drawMode LINES, draws lines of width=1, where you modify vertices each frame, should work for you. I unfortunately dont have time to make basic demos for you. If you give me more details, maybe i can throw you some pieces of code i have. The whole problem exists because on our lowest-level, webgl doesnt actually have lines Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 14, 2020 Share Posted October 14, 2020 Oh wait, sorry, I answered about "drawing 100000 different lines each frame", that's not what you asked. OK, two ways - 1. use renderTexture. 2. use Texture.from(canvas), draw it on canvas, do "texture.update()" each time you change something. Quote Link to comment Share on other sites More sharing options...
seraphpl Posted October 14, 2020 Author Share Posted October 14, 2020 Thanks, I'm able to do it now. ivan.popelyshev 1 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.