I don't think that making them smaller in LOVE (using the scale factor) would have any impact in the memory being used.
I tried canvases and I think it worked, , I load 149 images into the game without using canvas:
Code: Select all
for i,v in ipairs(love.filesystem.getDirectoryItems('assets/UI/PNG')) do
if v:find('.png') then
thumbs[#thumbs+1] = {love.graphics.newImage('assets/UI/PNG/'..v),love.graphics.newImage('assets/UI/PNG/'..v):getWidth() > love.graphics.getWidth()/5 +2 and
(love.graphics.getWidth()/5)/love.graphics.newImage('assets/UI/PNG/'..v):getWidth()
or love.graphics.newImage('assets/UI/PNG/'..v):getHeight() > love.graphics.getHeight()/8 +2 and
(love.graphics.getHeight()/8)/love.graphics.newImage('assets/UI/PNG/'..v):getHeight()
or 1} --calculated scaling factor
end
end
I then draw all the images to the screen with the calculated scale and task manager says that love is taking 42MB of RAM.
Then I test again using canvas:
Code: Select all
for i,v in ipairs(thumbs) do
local canvas = love.graphics.newCanvas(v[1]:getWidth()*v[2], v[1]:getWidth()*v[2])
love.graphics.setCanvas(canvas)
love.graphics.setColor(255, 255, 255)
love.graphics.draw(v[1], 0, 0, 0, v[2])
love.graphics.setCanvas()
thumbs[i][1] = canvas --replaces old big image with the new small canvas
end
And how can I compress a PNG into DXT, are there any tools to do this ?slime wrote:For even more RAM/VRAM usage optimization, you could convert the textures to DXT1 or DXT5 (depending on if they're fully opaque or not). DXT-compressed textures stay compressed in RAM and in VRAM, unlike regular image formats.