Jump to content
  • Advertisement
Sign in to follow this  
aphelix

little sprite line (transparent)

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

Hi! I make simple gui system.I use 10 sprite for ordinary window. 4 for corners, 4 for edges, 1 for bar and 1 for background. I calcul size and scale every sprite.But i get little line between transparent edges, corners and background.Why little line occurs? Thanks! ordinary

Share this post


Link to post
Share on other sites
Advertisement
How are you setting your texture coordinates? It sounds to me like you're not offsetting your vertices by 0.5px, and you're using transformed verts. You should subtract 0.5 from the X and Y coordinates of the vertices if you want a 1:1 mapping of texels to pixels. See the MSDN article Directly Mapping Texels to Pixels (Also in the SDK docs) for more information.

Share this post


Link to post
Share on other sites
ex for corner LT

// Initial Sprites Positions (Setting Sprite Transformation Matrix)
// CornerLT
D3DXMatrixTranslation(&mat, m_PositionLT.x, m_PositionLT.y, 0.0f);
m_Sprite[0]->SetTransformationMatrix(&mat);

and

window

Share this post


Link to post
Share on other sites
Is m_PositionLT offset by 0.5 pixels? And how are you setting the texture coordinates? Are the loaded textures powers of two in width and height? If not, are you using the correct flag (D3DX_NONPOW2 or something) with D3DXLoadTextureFromFileEx()? Assuming you're using D3DXLoadTextureFromFileEx()

Share this post


Link to post
Share on other sites
Is m_PositionLT offset by 0.5 pixels? No
loaded textures powers of two in width and height? Yes

I use sprite.

and Sprite


Sprite(TCHAR* _szTextureName)
{
HRESULT hr = 0;

hr = D3DXCreateSprite(DirectXInitialValues.Device, &m_pSprite);
if FAILED(hr)
RECORD_SINGLE_AND_RETURN(_T("> WARNING 17"));

_tcscpy((TCHAR*)m_szTextureName, (TCHAR*)_szTextureName);
if(D3D_OK != D3DXCreateTextureFromFile(DirectXInitialValues.Device, (TCHAR*)m_szTextureName, &m_pTexture)) //ex version exists
RECORD_SINGLE_AND_RETURN(_T("> WARNING 18"));

m_pImageInfo = (D3DXIMAGE_INFO*) malloc(sizeof(D3DXIMAGE_INFO));
......

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Sprite::Draw

bool Draw()
{
HRESULT hr;
D3DXMATRIX mat;

mat = m_TransformationMatrix;

hr = m_pSprite->Begin(m_Flag);
if FAILED(hr)
RECORD_SINGLE_AND_RETURN_1(_T("> WARNING 22"));

hr = m_pSprite->Draw(m_pTexture,NULL, &m_Center,&D3DXVECTOR3(m_PositionLT.x, m_PositionLT.y, 0.0f), 0xFFFFFFFF);
// hr = m_pSprite->Draw(m_pTexture,NULL, &m_Center, NULL, 0xFFFFFFFF);
if FAILED(hr)
RECORD_SINGLE_AND_RETURN_1(_T("> WARNING 24"));

hr = m_pSprite->End();
if FAILED(hr)
RECORD_SINGLE_AND_RETURN_1(_T("> WARNING 25"));

return 0;
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!