It might be silly, but I was playing Kerbal Space Program and noticed a setting in the graphics options labeled "Vsync:Every second Vblank". So this gots me to thinkin about L2d and my factory simulation. In my sim, love.draw() has two particular functions of concern. One for animations and one to print out all the text data. It's my assumption that animations and GUI stuff should probably be dealt with every frame. But the text data for the most part only changes about 40% - 50% of the time. This kinda seems like a waste of cpu cycles to keep printing out data that can only change every other frame or so.
So my question is how do I draw my text data every other frame? Every 4 frames? and so on?... Is this even possible? If so, how would I tackle this? If so, would this be a good or bad thing?
Thanks,
Controlling Love.Draw... Possible?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Controlling Love.Draw... Possible?
Isn't it going to flicker like hell if you only draw it every 4 frames?
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Controlling Love.Draw... Possible?
You can print the text to a canvas once, and then only redraw the canvas when the text needs updating, and draw the canvas itself every frame; that may save some cpu cycles, but it's not that much of a gain in my opinion.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Controlling Love.Draw... Possible?
I would imagine any gains made from doing this would be offset by problems or bugs introduced by messing with love.draw(). It's not like text takes very long to draw, anyway, so you'd probably spend more time implementing it than you'd save.
If you really are that concerned, use a canvas like zorg said, but unless you're actually having performance issues, I wouldn't worry about it (and if you are having performance issues, it's almost certainly something else, not drawing text every frame).
If you really are that concerned, use a canvas like zorg said, but unless you're actually having performance issues, I wouldn't worry about it (and if you are having performance issues, it's almost certainly something else, not drawing text every frame).
Possession - Escape from the Nether Regions, my roguelike made in LÖVE for the 2013 7-Day Roguelike Challenge
And its sequel, simply called Possession , which is available on itch.io or Steam, and whose engine I've open-sourced!
And its sequel, simply called Possession , which is available on itch.io or Steam, and whose engine I've open-sourced!
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Controlling Love.Draw... Possible?
I'm not sure I could recommend this but you can always tweak [wiki]love.run[/wiki] to your needs
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
- CaptainMaelstrom
- Party member
- Posts: 161
- Joined: Sat Jan 05, 2013 10:38 pm
Re: Controlling Love.Draw... Possible?
As others have mentioned, whatever CPU cycles you save will be offset by time spent developing your work-around, trouble-shooting and de-bugging it. Read up on the dangers of premature optimization!Grubby wrote:This kinda seems like a waste of cpu cycles...
Re: Controlling Love.Draw... Possible?
Modifying love.run doesn't sound like a good solution for this. If the text rendering is really expensive (and you've actually measured that it is a framerate bottleneck) then drawing the text on a canvas is a much better solution.
In general, rendering text is pretty cheap, so I wouldn't worry about it. If you're changing the text as often as every 2-3 frames then you won't save that much by using a Canvas anyway.
In general, rendering text is pretty cheap, so I wouldn't worry about it. If you're changing the text as often as every 2-3 frames then you won't save that much by using a Canvas anyway.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: Controlling Love.Draw... Possible?
Thanks guys!
Now why is it every time I ask a question in these forums I get pretty much the same answer?
"Don't do what you are planning to do because the gains you get won't be worth it..."
Of course, I generalize. Premature optimization? Whats that? Heh!
Now why is it every time I ask a question in these forums I get pretty much the same answer?
"Don't do what you are planning to do because the gains you get won't be worth it..."
Of course, I generalize. Premature optimization? Whats that? Heh!
Re: Controlling Love.Draw... Possible?
It's pretty hard to tell what's going to be worth it in the end, so you should be glad people are sharing their experiences
Somebody (maybe Robin or Kikito? can't remember) said something like this: First make it work. Then make it pretty. Then, if it's slow, you can start worrying about performance.
Somebody (maybe Robin or Kikito? can't remember) said something like this: First make it work. Then make it pretty. Then, if it's slow, you can start worrying about performance.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: Controlling Love.Draw... Possible?
Donald Knuth wrote:"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%"
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests