Page 1 of 1

Framerate drops when rendering more that 20 lines of text.

Posted: Fri Jul 06, 2018 5:00 pm
by codemon
Hello,

I've made a game with love engine(https://github.com/gsaga/Piano-Tiles). It has a debug region which is rendered besides the main game region and it displays logged messages and other debugging data. This region is rendered in love.draw.
See (https://github.com/gsaga/Piano-Tiles/bl ... in.lua#L43) and (https://github.com/gsaga/Piano-Tiles/bl ... er.lua#L41)

But the framerate drops horribly if the number of log lines goes above 15 or so lines. I'm sure it's because of the text because the game runs smooth as butter if the logging is effectively disabled by setting the number of log lines to be displayed to 0(https://github.com/gsaga/Piano-Tiles/bl ... ger.lua#L8).

The contents of the screen are reset between subsequent calls to love.draw, hence every iteration needs to paint the whole screen. Is there a way I can tell the engine to not do that(at least for some regions of the window)?
This would have many other use cases as well, like drawing some effects over the game area when the player wins(or looses) and blurring the background when a dialog is displayed.

Re: Framerate drops when rendering more that 20 lines of text.

Posted: Fri Jul 06, 2018 6:46 pm
by pgimeno
Try creating the lines to display as Text objects. See love.graphics.newText.

There's no way around starting drawing the screen from scratch each frame, but if you want to have a somewhat static part in the screen, or apply effects, you can use a canvas. The canvas will preserve its contents between frames, and you can draw it to the screen each frame.

Re: Framerate drops when rendering more that 20 lines of text.

Posted: Sat Jul 07, 2018 4:55 am
by codemon
pgimeno wrote: Fri Jul 06, 2018 6:46 pm Try creating the lines to display as Text objects. See love.graphics.newText.
That worked, thanks.