Hi,
I am trying to replace my sprite rendering code with quads for preparation of batching and I run into the following confusion.
I create a quad for the sprite, which for now I want to be the full image.
The way I read the wiki,
self.quad = love.graphics.newQuad( 0, 0, 256, 256, 256, 256 ) should give me a quad with the full texture, regardless of the texture's resolution. This is not the case so I am obviously misunderstanding something.
The wiki reads:
"The object is first scaled to dimensions sw × sh. The Quad then describes the rectangular area of dimensions width × height whose upper left corner is at position (x, y) inside the scaled object.È
So wouldn't the image be scaled to 256*256 and then draw the rectangle (0,0,256,256), ie, the whole image?
I know I can get it right by passing in image width and height, but I am confused as to the why - can someone explain what I am missing?
Edited to add: I'd expect the function to just do:
u0 = x/sw
v0 = y/sh
u1 = u0 + w/sw
v1 = v0 + h/sh
....but apparently that is not the case, and I'm curious what it does different to achieve the goal, isn't that all it would try to accomplish?
Thanks!
Kaj
Quad confusion
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Quad confusion
A Quad extracts a part of an image. Here i have an minimap_8.png which is 64*8 pixel big, but i want to draw only the first 8x8 pixel. It's basically for handling with texture atlas.
Code: Select all
self.minimapgfx = love.graphics.newImage("media/images/minimap/minimap_8.png")
self.wallquad = love.graphics.newQuad( 0, 0, 8, 8, self.minimapgfx:getWidth(), self.minimapgfx:getHeight() )
Re: Quad confusion
Thanks, but that part I understood.
I am puzzled why Quad(0,0,x,x,x,x) doesn't *always* draw the whole image.
Does the quad encode *output* size as well?
I am puzzled why Quad(0,0,x,x,x,x) doesn't *always* draw the whole image.
Does the quad encode *output* size as well?
Re: Quad confusion
Interesting!
Please post Love example.
I haven't experienced this.
I use (in love.load()):
and (in love.draw()):
which, I think, is exactly what you are doing.
Curious!
Edit: Think you may be confusing ImageDataWidth and ImageDataHeight with screen width and screen height. They're not related.
Please post Love example.
I haven't experienced this.
I use (in love.load()):
Code: Select all
ImageData = love.image.newImageData( ImageName )
ImageDataWidth, ImageDataHeight = ImageData:getWidth(), ImageData:getHeight()
ImageDataQuad = love.graphics.newQuad(0,0,ImageDataWidth,ImageDataHeight,ImageDataWidth,ImageDataHeight)
Image = love.graphics.newImage( ImageData )
Code: Select all
love.graphics.drawq( Image, ImageDataQuad, 0, 0 )
Curious!
Edit: Think you may be confusing ImageDataWidth and ImageDataHeight with screen width and screen height. They're not related.
Re: Quad confusion
Thanks, but no, I understand that.
I am trying to understand why I have to pass in imagewidth and height as it shouldn't be needed if it's only used for texture coordinates.
I don't understand why (based on the description in the wiki)
ImageDataQuad = love.graphics.newQuad(0,0,ImageDataWidth,ImageDataHeight,ImageDataWidth,ImageDataHeight)
doesn't do the same as
ImageDataQuad = love.graphics.newQuad(0,0,100,100,100,100
After all, all I am saying is -"the rect should draw the entire image", but apparently the last two are more than a reference width and height as I indeed have to pass image size, and I can't wrap my head around *why*
I am trying to understand why I have to pass in imagewidth and height as it shouldn't be needed if it's only used for texture coordinates.
I don't understand why (based on the description in the wiki)
ImageDataQuad = love.graphics.newQuad(0,0,ImageDataWidth,ImageDataHeight,ImageDataWidth,ImageDataHeight)
doesn't do the same as
ImageDataQuad = love.graphics.newQuad(0,0,100,100,100,100
After all, all I am saying is -"the rect should draw the entire image", but apparently the last two are more than a reference width and height as I indeed have to pass image size, and I can't wrap my head around *why*
- DaedalusYoung
- Party member
- Posts: 407
- Joined: Sun Jul 14, 2013 8:04 pm
Re: Quad confusion
I don't see the problem you're describing. I can do love.graphics.newQuad(0,0, 200,200, 200,200) just fine, that scales the image I use to 200x200 and it displays the entire scaled image.
What do you see happening? Is any part of the image cut off? Is the quad not the size you tell it to be?
Could you post your .love file?
What do you see happening? Is any part of the image cut off? Is the quad not the size you tell it to be?
Could you post your .love file?
Re: Quad confusion
I guess I am misreading what it says on the wiki.
When I say newQuad(0,0,200,200,200,200)
I expect to see the same as when I say newQuad(0,0,800,800,800,800), but I don't (which is apparently correct but I don't understand the logic).
I thought quad only set the texture coords but it seems to set texture coords and size - it scales the object, whereas I interpreted it as 'scales the image'.
I'll play around with the numbers to see if I can grasp it correctly
When I say newQuad(0,0,200,200,200,200)
I expect to see the same as when I say newQuad(0,0,800,800,800,800), but I don't (which is apparently correct but I don't understand the logic).
I thought quad only set the texture coords but it seems to set texture coords and size - it scales the object, whereas I interpreted it as 'scales the image'.
I'll play around with the numbers to see if I can grasp it correctly
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Quad confusion
It also determines the size of the quad from those numbers, which is what you're seeing, I suspect.
Re: Quad confusion
Yes, that was what I was seeing. I misinterpreted 'scales up the object to sx, sy' as it scaling up the image object (virtually that is) so it could calculate uv coords. But it operates on pixel coords purely and the object being scaled was the actual rendered object.
Thanks for the help everyone )
Thanks for the help everyone )
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Quad confusion
It does calculate uv coordinates from them, but it's also used to determine the size.
Who is online
Users browsing this forum: Ahrefs [Bot] and 78 guests