"Questions that don't deserve their own thread" thread

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.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: "Questions that don't deserve their own thread" thread

Post by Ranguna259 »

Oh I didn't detect his sarcasm :P , I can't create a new file because the images are going to be dynamicly modified, and the 4096x4096 image was just an exemple, I'm not gonna use an image that big (some GPU can't even handle those kind of dimensions).
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
(if you don't understand the scaling calculator then ignore it, just know that the return value is <= 1)
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 the memory lowers to 40MB, pretty cool huh ?
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.
And how can I compress a PNG into DXT, are there any tools to do this ?
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by slime »

Ranguna259 wrote:And how can I compress a PNG into DXT, are there any tools to do this ?
Yep: viewtopic.php?f=4&t=77364&p=163754#p163754
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: "Questions that don't deserve their own thread" thread

Post by Ranguna259 »

Thank you, but dds can't handle power of two.. I'll just alpha the pixels untill it's good, I'll have a problem with this LOVE using (image:getWidth() and image:getHeight()), anyhow this is great for memory optimizations.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by slime »

Ranguna259 wrote:Thank you, but dds can't handle power of two.. I'll just alpha the pixels untill it's good, I'll have a problem with this LOVE using (image:getWidth() and image:getHeight()), anyhow this is great for memory optimizations.
The DXT formats (in the dds container) handle non-power-of-two image dimensions fine - as long as the system has NPOT support (if love.graphics.isSupported("npot") is true.)
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: "Questions that don't deserve their own thread" thread

Post by Ranguna259 »

The problem is that the nvidia app for PS won't save images unless they are power-of-two, I'll just use gimp instead.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by bartbes »

Ranguna259 wrote:
bartbes wrote:Tables that contain no other tables.
Aren't flat tables, tables in strings
I'm fairly sure I wrote that part of the docs, so no. They are tables that contain no other tables.
Ranguna259 wrote:Oh I didn't detect his sarcasm
Probably because that wasn't sarcasm.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: "Questions that don't deserve their own thread" thread

Post by Ranguna259 »

bartbes wrote: I'm fairly sure I wrote that part of the docs, so no. They are tables that contain no other tables.
Ah, thanks for the clarification :megagrin:
bartbes wrote: Probably because that wasn't sarcasm.
Wrong term, is there a term for "asking but actually saying" ?
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: "Questions that don't deserve their own thread" thread

Post by davisdude »

Ranguna259 wrote:Wrong term, is there a term for "asking but actually saying" ?
Implying?
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by bartbes »

Ranguna259 wrote: Wrong term, is there a term for "asking but actually saying" ?
A rhetorical question, I suppose.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: "Questions that don't deserve their own thread" thread

Post by Ranguna259 »

bartbes wrote: A rhetorical question, I suppose.
davisdude wrote: Implying?
Hmmm.. Despite the fact that they differ from each other, both are right.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
Locked

Who is online

Users browsing this forum: Google [Bot] and 37 guests