"Questions that don't deserve their own thread" thread
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- 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
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 ?
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: "Questions that don't deserve their own thread" thread
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?
Re: "Questions that don't deserve their own thread" thread
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?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 ?
That's all?
- 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
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
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: "Questions that don't deserve their own thread" thread
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.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.
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 ).
GPUs don't rasterize pixels that aren't inside the screen, although I'm not sure if that's what you mean.Whatthefuck wrote:Do quads have culling optimization?
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: "Questions that don't deserve their own thread" thread
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?slime wrote: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.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.
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 ).
GPUs don't rasterize pixels that aren't inside the screen, although I'm not sure if that's what you mean.Whatthefuck wrote:Do quads have culling optimization?
Re: "Questions that don't deserve their own thread" thread
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).
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: "Questions that don't deserve their own thread" thread
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.)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?
Re: "Questions that don't deserve their own thread" thread
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...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
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
- 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
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 ?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
And since this removes the scalling compatibility then it would be no longer an optimization but rather a downgrade
Regarding the color fancy stuff, I just used colors to make the tutorial a little easier to understand.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests