Pointers on a 2D library in D3D?
Anybody have any pointers on setting up a tile library inside D3D? Mine has been going awful and I think I'm going to write that class over from scratch. I keep getting lines from where it renders part of the tiles next to it.
FYI, here's the equation to figure out the tile location...
PANEL_CUSTOMVERTEX* pVertices = NULL;
m_pVertexBuffer->Lock(0, 4 * sizeof(PANEL_CUSTOMVERTEX), (BYTE**)&pVertices, 0);
float startx = (float)(index % amnt_across) * index_width,
starty = (float)(index / amnt_down) * index_height;
//Set the texture coordinates of the vertices
pVertices[0].u = startx;
pVertices[0].v = starty + index_height;
pVertices[1].u = startx;
pVertices[1].v = starty;
pVertices[2].u = startx + index_width;
pVertices[2].v = starty + index_height;
pVertices[3].u = startx + index_width;
pVertices[3].v = starty;
m_pVertexBuffer->Unlock();
Basically I'm using this method because it works quite well under 2D circumstances.
[edited by - Ðragun on April 11, 2004 1:47:51 PM]
two things:
1: Read up in the SDK about texelixel mappings; theres a nice article on getting pixel-perfect mappings. I forget what the rules are, but its generally +-0.5px (to get the center points for texel mapping).
2: Disable texture filtering and enable texture clamping (U and V). As long as you''re not doing a lot of rotation/scaling (unlikely for a tile engine) you''ll get perfectly good and accurate results.
hth
Jack
1: Read up in the SDK about texelixel mappings; theres a nice article on getting pixel-perfect mappings. I forget what the rules are, but its generally +-0.5px (to get the center points for texel mapping).
2: Disable texture filtering and enable texture clamping (U and V). As long as you''re not doing a lot of rotation/scaling (unlikely for a tile engine) you''ll get perfectly good and accurate results.
hth
Jack
In general, you must add 0.5/TextureWidth to U coord (1-0.5/TexW and 0+ 0.5/TexW)
and add 0.5/TextureHeight to V coord.
and add 0.5/TextureHeight to V coord.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement