Need Help with faster Rendering

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
lauriszz123
Prole
Posts: 11
Joined: Thu Oct 04, 2018 1:01 pm

Need Help with faster Rendering

Post 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
daviel
Prole
Posts: 13
Joined: Tue Apr 17, 2018 5:10 pm

Re: Need Help with faster Rendering

Post 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.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Need Help with faster Rendering

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests