Page 1 of 1
how to saving memory
Posted: Sat Jul 30, 2016 10:20 am
by pielago
love.graphics.setDefaultFilter(nearest,nearest) for sure this will help memory and speed and frame rate...makes small images bigger onscreen
but in my case I want to make a spritesheet with 64x64 and 128x128 and don't want to kill the memory
I want the images to look smaller on screen I played around with filter and love.draw() but none worked
and was not able to make my 64 and 128 look like a 32x32
perhaps I missed something can someone help me ?
- cube.love
- cube
- (67.67 KiB) Downloaded 172 times
Re: how to saving memory
Posted: Wed Aug 03, 2016 9:53 pm
by rmcode
I'm not sure what exactly you are asking here.
doesn't have much to do with memory usage. It just determines which
FilterMode is used while scaling your images.
It looks like something in your code is producing a lot of garbage each frame (and I supposed this is what you are trying to reduce). Generally you should try to avoid creating tables each frame. E.g.:
Code: Select all
love.graphics.setColor( unpack{ fontcolor } )
can be simply rewritten as:
Code: Select all
love.graphics.setColor( fontcolor )
I'd say if you get rid of all those unpack statements you have in your code it should already greatly improve garbage usage. That's the only big issue I saw while glancing over your code.
Re: how to saving memory
Posted: Thu Sep 08, 2016 9:46 am
by pielago
Oh ..thanks so much ..i don't want to over kill this ,as for the images the scale
will this work to make my 128x128 images to 32x32 and save memory as well?? or wont work?
https://love2d.org/wiki/love.graphics.scale
Re: how to saving memory
Posted: Thu Sep 08, 2016 10:16 am
by zorg
Let's say that you load a 128x128 image that uses 8 bits for 4 channels (red, green, blue, alpha). The raw data will take up 128*128*4 bytes, which is 65536 bytes, which is 64 kilobytes. Not much. 64x64 is even smaller, with 64*64*4 = 16 kilobytes.
Both disk space and memory will be around those values, maybe a bit more for headers, maybe a bit less because compression.
As for speed, it literally does not matter. The slowest thing would be loading in the file from disk to memory, but you should only do that once anyway, so it is meaningless. Drawing out a 64x64 and a 128x128 image takes about the same time.
Both love.graphics.scale and the sx, sy parameter for love.graphics.draw are the same in functionality, you could use either. For your case, you want a scale factor of 32/128 for both axes, which is 0.25. It will work in that your images will have a size of 32x32 on screen. It has nothing to do with memory usage, or speed.
Re: how to saving memory
Posted: Thu Sep 22, 2016 8:14 am
by pielago
thanks you so much for the answer.
I do see many great games with such great graphics ( computers and/or cells ) clash of clans as an example to me looks like a 2D game but the graphics are so nice ( I question my self if it is the programmer or the artist? ) for such nice result!
and that's what I want to achieve.
Re: how to saving memory
Posted: Thu Sep 22, 2016 8:19 am
by rmcode
pielago wrote:thanks you so much for the answer.
I do see many great games with such great graphics ( computers and/or cells ) clash of clans as an example to me looks like a 2D game but the graphics are so nice ( I question my self if it is the programmer or the artist? ) for such nice result!
and that's what I want to achieve.
Clash of Clans is developed by a professional studio so chances are they have more than one artist
I haven't played clash of clans, but it looks like 3d models rendered to 2d sprites. You basically can do the very same with LÖVE.
Re: how to saving memory
Posted: Thu Sep 22, 2016 8:28 am
by pielago
oh! you say its render???
now for TERRARIA its computer game...is that also render from 3D to 2D?????
Re: how to saving memory
Posted: Thu Sep 22, 2016 8:34 am
by rmcode
pielago wrote:oh! you say its render???
now for TERRARIA its computer game...is that also render from 3D to 2D?????
No, sprites in Terraria are hand-drawn.