Optimize image loading / displaying

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
Mirk
Prole
Posts: 3
Joined: Fri Feb 10, 2017 5:23 pm

Optimize image loading / displaying

Post by Mirk »

Hi !

I recently start on LÖVE (my sweet LÖVE !) and I try to done a citybuilder with isometric tile.
The display of the map is dynamic (autosize with the size of the windows).
For a fullscreen on 1920x1080, I display ~2300 images (one tile : 60x30) with 60 FPS. But with dual screen (3840x1080) I fall at 40 FPS and the main thread is overloaded.

I use love.graphics.newImage() and love.graphics.draw()
Is there a more optimized way to display images ?
You can find in attached my .love file

Thanks (sorry for mistakes, I'm French :S)
Attachments
TestLove.love
(126.54 KiB) Downloaded 173 times
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Optimize image loading / displaying

Post by raidho36 »

Most of the workload here is GPU draw calls. Use spite batch to reduce number of draw calls. You can try using autobatch library with no code modification, be aware however that switching to a different sprite, switching shader, switching color etc. breaks the batch and starts a new one, and you'll need a draw call per each batch.
User avatar
darkmetalic
Prole
Posts: 17
Joined: Tue Feb 07, 2017 4:09 pm
Contact:

Re: Optimize image loading / displaying

Post by darkmetalic »

Since you are organizing numerically, enjoy it

Code: Select all

Test = {}
for i=1, 58 do
Test[i] = love.graphics.newImage("Terrain/Land1a_00"..(121+i)..".png")
end
Zireael
Party member
Posts: 139
Joined: Fri Sep 02, 2016 10:52 am

Re: Optimize image loading / displaying

Post by Zireael »

Is there a way to batch lines written using love.graphics.print?
Mirk
Prole
Posts: 3
Joined: Fri Feb 10, 2017 5:23 pm

Re: Optimize image loading / displaying

Post by Mirk »

raidho36 wrote: Fri Feb 24, 2017 10:12 am Most of the workload here is GPU draw calls. Use spite batch to reduce number of draw calls. You can try using autobatch library with no code modification, be aware however that switching to a different sprite, switching shader, switching color etc. breaks the batch and starts a new one, and you'll need a draw call per each batch.
I tried but no change, because I have too many different images on my screen.
darkmetalic wrote: Fri Feb 24, 2017 10:45 am Since you are organizing numerically, enjoy it

Code: Select all

Test = {}
for i=1, 58 do
Test[i] = love.graphics.newImage("Terrain/Land1a_00"..(121+i)..".png")
end
Yes ^^ (It's just a quick test)
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Optimize image loading / displaying

Post by raidho36 »

If you use an image atlas you can definitely leverage batching more easily, since they're all on the same texture and if it never has to switch the batch is never broken.
Mirk
Prole
Posts: 3
Joined: Fri Feb 10, 2017 5:23 pm

Re: Optimize image loading / displaying

Post by Mirk »

raidho36 ! I want to say you one thing : I löve you !
I already knew this way but not his name (thanks for the information) and I never used it.
You can find in attached the new .love file with a texture atlas.

Many thanks for this help !

PS : like many of my questions on english forums, it's more a lack of keywords than a real problem ^^ sorry for that :S
Attachments
TestLoveBis.love
(87.42 KiB) Downloaded 164 times
Last edited by Mirk on Sat Feb 25, 2017 9:06 am, edited 1 time in total.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Optimize image loading / displaying

Post by Positive07 »

If you are using a texture atlas then you should be using an SpriteBatch!
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 48 guests