Jump to content
  • Advertisement

Archived

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

Maverick the divider

0.5 pixel non-precision

This topic is 5877 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

I''m using ortho mode for 2d graphics. Drawing triangle strips with textures, but if the texture has a non-transparent pixel right near the border, it creates some sort of "noise" on the other side. I could post a screenshot somewhere... This is my temporary creation routine: (TWidth, THeight are texture sizes) (HRect is my RECT class) ----------------------------------------- CImage::CImage(float TWidth, float THeight, HRect *Source, CGraphics *Graphics) { // Vertex buffer Graphics->pDevice->CreateVertexBuffer(sizeof(CVertex)*4, NULL, FVF.D3DFVF_CVertex, D3DPOOL_MANAGED, &VertexBuffer); CVertex *VertexArray; VertexBuffer->Lock(0, 0, (BYTE **)&VertexArray, NULL); VertexArray[0] = CVertex(0.0f, 0.0f, 1.0f, (Source->iLeft - 1)/TWidth, (Source->iBottom + 1)/THeight); VertexArray[1] = CVertex(Source->iRight - Source->iLeft + 1, 0.0f, 1.0f, (Source->iRight + 1)/TWidth, (Source->iBottom + 1)/THeight); VertexArray[2] = CVertex(0.0f, Source->iBottom - Source->iTop + 1, 1.0f, (Source->iLeft - 1)/TWidth, (Source->iTop - 1)/THeight); VertexArray[3] = CVertex(Source->iRight - Source->iLeft + 1, Source->iBottom - Source->iTop + 1, 1.0f, (Source->iRight + 1)/TWidth, (Source->iTop - 1)/THeight); VertexBuffer->Unlock(); } The wisest men say: Keep it simple, stupid

Share this post


Link to post
Share on other sites
Advertisement
mess with the renderstates. on should be how textures are addresses (D3DRS_TEXTUREADRESSU and D3DRS_TEXTUREADRESSV i think)and you should make this D3D*_CLAMP instead of D3D*_WRAP. check the docs, its pretty easy to find. this will prevent the card from wraping texture values, but may not fix your problem, however there shoudl also be a renderstate that also dictates how to change how filtering is done. worse case add a one pixel border around your texture.

Share this post


Link to post
Share on other sites
if your drawing a quad just subtract 0.5 from the vertext coordinates of the top and left sides of the quad. Worked like a champ for me.

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!