Original Post
I have a question about vertex coordinates concerning 2D textured quads. As you all know, textured quads are measured in screen units (pixels), so having said this I can proceed with my question: Currently, I use the following structure to define a rectangle on the screen: As you can see, the top left is at pixel 0, and the top right pixel is at pixel 7. This means the quad is actually 8 pixels wide, since pixel 7 is actually the 8th pixel (starting from 0). To make things even more unusual, this method is actually correct and creates a quad that is 7 pixels wide. The math isn't making sense for some reason. Can someone explain this a bit for me? Thanks...
struct Rect
{
int x;
int y;
int width;
int height;
}
When setting up the 4 vertices that compose of the quad, I was wondering if the bottom and right edges are measured like Win32 RECT's are measured in GDI, that is, the right and bottom edges are -1 pixel short. I'm having a hard time explaining this, so allow me to show some examples: Assume that I want to create a textured quad that starts at 0,0 (top left of the screen) and is 7 pixels wide and 7 pixels high. So, I would create a Rect object as follows: Rect r;
r.x = 0;
r.y = 0;
r.width = 7;
r.height = 7; Now, when I create my quad, I create my vertex array as follows: Vertex v[4];
// Top Left of Quad
v[0].x = r.x;
v[0].y = r.y;
// Top Right of Quad
v[1].x = r.x + r.width;
v[1].y = r.y;
// Bottom Right of Quad
v[2].x = r.x + r.width;
v[2].y = r.y + r.height;
// Bottom Right of Quad
v[3].x = r.x;
v[3].y = r.y + r.height;