Taking too much time to draw
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Taking too much time to draw
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 161 times
Re: Taking too much time to draw
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.
You need to use render batching.
-
- Party member
- Posts: 234
- Joined: Mon Aug 29, 2016 8:51 am
Re: Taking too much time to draw
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.
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.
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Taking too much time to draw
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 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.
- bjornbytes
- Prole
- Posts: 12
- Joined: Sat Oct 10, 2015 8:17 pm
- Contact:
Re: Taking too much time to draw
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.
Re: Taking too much time to draw
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é
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Who is online
Users browsing this forum: Google [Bot], Google Adsense [Bot] and 17 guests