GodofDrakes [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=20613 Stateless Rendering <p> <table><tr><td> <a href="/bbs/?pid=57405#p"> <img src="/bbs/thumbs/pico57404.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=57405#p"> Stateless Rendering 1</a><br><br> by <a href="/bbs/?uid=20613"> GodofDrakes</a> <br><br><br> <a href="/bbs/?pid=57405#p"> [Click to Play]</a> </td></tr></table> </p> <p>I work with C++ for a living and to kill time while waiting for projects to compile I occasionally read C++ articles. One that caught my eye was <a href="https://blog.molecular-matters.com/2014/11/06/stateless-layered-multi-threaded-rendering-part-1/">this series of articles on creating a stateless renderer</a>. I really wanted to try it but then realized that setting up a proper opengl project would take forever and require miles of boilerplate code. Forget that! PICO-8 to the rescue!</p> <p>Obviously some changes had to be made to accommodate PICO-8 and lua but the core idea is still there. As each entity is updated it adds the necessary commands to draw itself to a buffer. It also generates a key used to 'sort' these commands. The end result is the ability to iterate over entities in any order and always have them drawn in the correct order. Additionally, you don't have to iterate over the entities more than once. Calculating the key can be done at the same time as the rest of the entity's update logic. The built in draw function only ever touches the draw command buffer.</p> <p>I have done absolutely no profiling or optimizations on this. In theory this is supposed to be super performant but the article was written with a C/C++ project in mind and those performance benefits probably don't translate over to lua 1:1. Also ignore the entity/component stuff. That's just leftovers from a previous idea that I carried over. Also it probably takes up a lot more tokens than is necessary.</p> https://www.lexaloffle.com/bbs/?tid=31986 https://www.lexaloffle.com/bbs/?tid=31986 Tue, 02 Oct 2018 19:10:35 UTC