Page 1 of 1

Need Help with faster Rendering

Posted: Thu Oct 04, 2018 1:05 pm
by lauriszz123
Hello there, I'm new to the forums, but by no means I'm new to Lua and Love2D!

So okay, I'm rendering a table with RGB data, but doing so with the CPU, how can I render it faster for more FPS. THANKS!

main.lua file is here: https://github.com/lauriszz123/LuaOS/bl ... r/main.lua

Re: Need Help with faster Rendering

Posted: Sat Oct 06, 2018 9:38 am
by daviel
So as far I understand your draw routine it looks like you're trying to draw every single pixel on the screen as a draw point instruction. This is a really slow approach to try to render things. So to help you we would need to know what you really want to try to achieve.

Re: Need Help with faster Rendering

Posted: Sat Oct 06, 2018 4:07 pm
by pgimeno
ImageData is your friend, in this case. Rather than having the gfx table, store the graphics data in an ImageData object. It has ImageData:setPixel and ImageData:getPixel methods; however, maybe it's faster to use its :getPointer() method to access it through FFI.

Then, have an Image object with the same dimensions ready for drawing. In the draw callback, use (Image):replacePixels to transfer the ImageData to the Image, and draw the Image.