"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.
Locked
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 »

I was wondering if there was a better way to draw a grid that is compatible with translation and scalling than this(use arrow keys and mouse wheel). Do you guys know of any better way ?
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.
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

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

Post by Whatthefuck »

I noticed that regardless of how large a quad's size is in the repeating mode, it doesn't seem to use more memory. Do quads have culling optimization?
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

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

Post by Plu »

Ranguna259 wrote:I was wondering if there was a better way to draw a grid that is compatible with translation and scalling than this(use arrow keys and mouse wheel). Do you guys know of any better way ?
Probably. The idea is to draw a grid with lines, which are red if they're outside the 0,0 viewport and blue otherwise, with a scaling factor?

That's all?
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 »

That's what the code already does, but it loops around 3 times throught all lines, it might get laggy, but if this is the best way then I might write this on the loveblog, if no one minds :P
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: 3166
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 »

Whatthefuck wrote:I noticed that regardless of how large a quad's size is in the repeating mode, it doesn't seem to use more memory.
A Quad only has information about the position, size, and texture coordinates of the vertices drawn when you do love.graphics.draw(texture, quad, ...). The actual Quad object always has a constant size of ~80 bytes.

The repeating is done by the GPU when it draws the image to the screen (in the pixel shader stage in this example: http://data.simonschreibt.de/gat049/pip ... rview.webm ).
Whatthefuck wrote:Do quads have culling optimization?
GPUs don't rasterize pixels that aren't inside the screen, although I'm not sure if that's what you mean.
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

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

Post by Whatthefuck »

slime wrote:
Whatthefuck wrote:I noticed that regardless of how large a quad's size is in the repeating mode, it doesn't seem to use more memory.
A Quad only has information about the position, size, and texture coordinates of the vertices drawn when you do love.graphics.draw(texture, quad, ...). The actual Quad object always has a constant size of ~80 bytes.

The repeating is done by the GPU when it draws the image to the screen (in the pixel shader stage in this example: http://data.simonschreibt.de/gat049/pip ... rview.webm ).
Whatthefuck wrote:Do quads have culling optimization?
GPUs don't rasterize pixels that aren't inside the screen, although I'm not sure if that's what you mean.
So basically I can have a huge quad that is meant for parallax scrolling and if the majority of it is off-screen it won't impact the performance at all?
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

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

Post by Plu »

You'll still have to keep that huge image in memory, so that will impact performance somewhat (mostly in how much memory it'll take up).
User avatar
slime
Solid Snayke
Posts: 3166
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 »

Whatthefuck wrote:So basically I can have a huge quad that is meant for parallax scrolling and if the majority of it is off-screen it won't impact the performance at all?
If the quad is big but the image is not, yes (otherwise the image will be taking up a lot of space in RAM and VRAM.)
Wojak
Party member
Posts: 134
Joined: Tue Jan 24, 2012 7:15 pm

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

Post by Wojak »

Ranguna259 wrote:That's what the code already does, but it loops around 3 times throught all lines, it might get laggy, but if this is the best way then I might write this on the loveblog, if no one minds :P
If you want just translation (no scaling), you know the exact grid size and no fancy color stuff I would recommend generating it with imageData and SpriteBatch and draw it all with one cal...

but if you want all the fancy stuff You may stil consider improving the performance bay not using love.graphic.line...

in love.load:

Code: Select all

line = love.image.newImageData(1,1)
line:setPixel(0,0,255,255,255,255)
line = love.graphics.newImage(line)
love.graphics.line = function(x,y,x1,y1)
	if x == 0 then
		love.graphics.draw( line, x, y, 0, x1, 1)
	else
		love.graphics.draw( line, x, y, 0, 1, y1)
	end
end
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 »

Wojak wrote:

Code: Select all

line = love.image.newImageData(1,1)
line:setPixel(0,0,255,255,255,255)
line = love.graphics.newImage(line)
love.graphics.line = function(x,y,x1,y1)
	if x == 0 then
		love.graphics.draw( line, x, y, 0, x1, 1)
	else
		love.graphics.draw( line, x, y, 0, 1, y1)
	end
end
Are you saying that drawing a pixel and scalling it to look like a line would be faster then using the actual love.graphics.line() function ?
And since this removes the scalling compatibility then it would be no longer an optimization but rather a downgrade :P
Regarding the color fancy stuff, I just used colors to make the tutorial a little easier to understand.
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: Ahrefs [Bot], Google [Bot] and 15 guests