Taking too much time to draw

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
pauls313
Prole
Posts: 49
Joined: Tue Aug 02, 2016 3:07 am

Taking too much time to draw

Post by pauls313 » Thu Sep 08, 2016 7:05 pm

My code iterates through a tile table every frame to draw it, but it's taking way too long. It's running at 10FPS.
Attachments
lovegame.love
(688.88 KiB) Downloaded 56 times

User avatar
raidho36
Party member
Posts: 1951
Joined: Mon Jun 17, 2013 12:00 pm

Re: Taking too much time to draw

Post by raidho36 » Thu Sep 08, 2016 8:44 pm

Well you're rendering 10 000+ objects without using batches or anything of the sort, so pretty much every draw operation translates to at least one GPU render call. And 10k+ draw calls is insane number, GPUs normally deal with few tens at most.

You need to use render batching.

KayleMaster
Party member
Posts: 212
Joined: Mon Aug 29, 2016 8:51 am

Re: Taking too much time to draw

Post by KayleMaster » Thu Sep 08, 2016 9:13 pm

Definitely need to batch those sprites (look up spriteBatch love2d).
I'm using 9 spriteBatches and I am drawing 36864 tiles (32*16) in my game at 512 fps on a low end pc. Basically, the difference is, that it's 1 draw call instead of 10000 and that's what makes it faster. However they can be tricky to implement.


User avatar
zorg
Party member
Posts: 2732
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Taking too much time to draw

Post by zorg » Thu Sep 08, 2016 11:03 pm

I also looked at the code, and apart from not being indented at all, you also redefine love.keywhatever each time love.update is called. That's not how it works, and that's not how you should do it; Define it outside love.update. Or use the isDown function in update.
Me and my stuff :3True 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.

User avatar
bjornbytes
Prole
Posts: 12
Joined: Sat Oct 10, 2015 8:17 pm
Contact:

Re: Taking too much time to draw

Post by bjornbytes » Fri Sep 09, 2016 4:00 am

I just made something that might help with this: glance. You basically wrap your draw operations in glance.render() which will save things to a Canvas if they don't change very much -- it's a tradeoff between draw calls and texture memory. If you're able to use a SpriteBatch though, that would be the best way to do things.

User avatar
Karai17
Party member
Posts: 879
Joined: Sun Sep 02, 2012 10:46 pm

Re: Taking too much time to draw

Post by Karai17 » Fri Sep 09, 2016 10:11 am

If you're using a tilemap, you shoudl check out STI and try using Tiled to make your maps. This is very much a solved problem.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 9 guests