Original Post
The texture coords for a DirectX8 graphics core I converted from VB6 to C++ are sometimes off by a pixel. Also, the texture grabs too much of a pixel on the edges... For example, I have a square with a 1 pixel thick black border. When I draw it, the left side of the border is 2 pixels wide and the top of the border is 2 pixels wide as well. The right and bottom seem to be fine in most cases (I suspect however that they disappear sometimes). I was originally thinking it had to do with the floating points I had to use, however I doubt a problem like this can be caused by that... It's like DX is stretching it on the left and shrinking it on the right. The graphics I'm using are 2D, not 3D model based. I'm using the following FVF: D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1 Here is the vertex struct: Here is a small sample of the calculations, I can give more if you need it: Oh also, this does not seem to happen all the time, and generally only if the texture's tu and tv is 0. VBStrider [Edited by - VBStrider on February 5, 2006 8:50:11 PM]
// Transformed and lit vertex.
typedef struct TAG_TLVERTEX
{
FLOAT x;
FLOAT y;
FLOAT z;
FLOAT rhw;
DWORD color;
DWORD specular;
FLOAT tu;
FLOAT tv;
} TLVERTEX;
fTmpX = fX;
fTmpY = fY + iHeight;
// 0 - Bottom Left Vertex
tlVerts[0].x = fTmpX;
tlVerts[0].y = fTmpY;
tlVerts[0].z = 0;
tlVerts[0].rhw = 1;
tlVerts[0].specular = 1;
tlVerts[0].color = _RGB32BIT(bA1, bR1, bG1, bB1);
tlVerts[0].tu = (float)rctSource.left / desc.Width;
tlVerts[0].tv = (float)rctSource.bottom / desc.Height;


