Hello all
I have recently upgraded all my engine logic to use sprite-batches with large unevenly sized images.
For now, I have cut out some of the code and made a stand-alone example for your perusal. Nothing too fancy though, just does the following:
Creates an atlas from different sized graphics assets (automated) and packed in height order (first idea from head).
The atlas is saved out with quad information, and is loaded in on the next run.
and Demonstrates rendering some quads with a sprite-batch.
Edit* Question for you guys:
What is the significance of the spritebatch 'maxsprites ' ?
spriteBatch = love.graphics.newSpriteBatch( image, maxsprites )
Is there some sort of performance hit. I just can't see why there is a limit. Thank you all.
Spritebatch Atlas Creator & Example
-
- Party member
- Posts: 134
- Joined: Tue Mar 29, 2011 11:05 pm
Spritebatch Atlas Creator & Example
- Attachments
-
- sb_atlas.love
- Code!
- (62.94 KiB) Downloaded 212 times
-
- 10_512_Quads.lua
- Accompanying quads for example atlas
- (660 Bytes) Downloaded 137 times
Last edited by drunken_munki on Wed Nov 15, 2017 12:52 pm, edited 2 times in total.
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Sritebatch Atlas Creator & Example
The limit is probably because you can't create a batch without a specified amount. In c++ and opengl things are not as flexible as lua. I would assume the batch is like an array where you can not resize it after it is created.
- RainbowOverdose
- Prole
- Posts: 4
- Joined: Sat Jan 30, 2016 12:37 pm
- Location: Almería, Spain
Re: Spritebatch Atlas Creator & Example
You could write an ensureCapacity function if you really need it and emulate a dinamic behavior for that spritebatch, but, there must be some other way to do it since Lua uses table for everything... So ensure sapacity probably is not a good choise in this case
Life is a cycle that knows no end.
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Spritebatch Atlas Creator & Example
Lua uses tables but not the actual code that creates the batch. So a dynamic batch probably not possible and if it is resizing would be slow.RainbowOverdose wrote:You could write an ensureCapacity function if you really need it and emulate a dinamic behavior for that spritebatch, but, there must be some other way to do it since Lua uses table for everything... So ensure sapacity probably is not a good choise in this case
- RainbowOverdose
- Prole
- Posts: 4
- Joined: Sat Jan 30, 2016 12:37 pm
- Location: Almería, Spain
Re: Spritebatch Atlas Creator & Example
Did you ever emulated a linked list with an array? it's possible, but, you are right, it's slow.bobbyjones wrote:Lua uses tables but not the actual code that creates the batch. So a dynamic batch probably not possible and if it is resizing would be slow.RainbowOverdose wrote:You could write an ensureCapacity function if you really need it and emulate a dinamic behavior for that spritebatch, but, there must be some other way to do it since Lua uses table for everything... So ensure sapacity probably is not a good choise in this case
Life is a cycle that knows no end.
- slime
- Solid Snayke
- Posts: 3160
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Spritebatch Atlas Creator & Example
It determines the amount of video memory (and regular memory) that the SpriteBatch uses. It also affects how much data is copied from main memory to video memory when the SpriteBatch is drawn (or if [wiki]SpriteBatch:flush[/wiki] is called), for streaming SpriteBatches.drunken_munki wrote: What is the significance of the spritebatch 'maxsprites ' ?
spriteBatch = love.graphics.newSpriteBatch( image, maxsprites )
Is there some sort of performance hit. I just can't see why there is a limit. Thank you all.
There is a performance hit (and a memory increase) for specifying a much higher number than what you actually use.
-
- Party member
- Posts: 134
- Joined: Tue Mar 29, 2011 11:05 pm
Re: Spritebatch Atlas Creator & Example
Interesting, thanks for that. I will probably do some testing when I get a chance and I'll post the results.It determines the amount of video memory (and regular memory) that the SpriteBatch uses. It also affects how much data is copied from main memory to video memory when the SpriteBatch is drawn (or if SpriteBatch:flush is called), for streaming SpriteBatches.
There is a performance hit (and a memory increase) for specifying a much higher number than what you actually use.
Who is online
Users browsing this forum: Google [Bot] and 1 guest