Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Dragun

Pointers on a 2D library in D3D?

This topic is 5159 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!