Framerate drops when rendering more that 20 lines of text.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
codemon
Prole
Posts: 2
Joined: Fri Jul 06, 2018 4:40 pm

Framerate drops when rendering more that 20 lines of text.

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

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

Post 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.
codemon
Prole
Posts: 2
Joined: Fri Jul 06, 2018 4:40 pm

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

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

Who is online

Users browsing this forum: Semrush [Bot] and 7 guests