Jump to content
  • Advertisement
Sign in to follow this  
Feynman Su

Problem with showing a mirror texture

This topic is 4846 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 have a problem about using the DirectX 9.0 When I use DrawPrimitiveUP with the texture created from CreateD3D9Texture (), It looks like this m_pD3D9Dev->DrawPrimitiveUP ( D3DPT_TRIANGLESTRIP, 2, t2DTexture->m_stTVB, sizeof ( stCUSTOMVERTEX ) ); and then I change the the u, v or change the 4 vectors of the polygon to do a mirror effect of the texture, it seems that I get a wrong result! The texture mirrored, but still left one pixel line that stay in it's original place, always the top one or the leftest one of the texture! Could anyone please tell me what I have been done wrong?

Share this post


Link to post
Share on other sites
Advertisement
I think this may be a rounding error when you calculate your mirrored uv's. How do you exactly calculte them ?

Share this post


Link to post
Share on other sites
struct stCUSTOMVERTEX
{
FLOAT x;
FLOAT y;
FLOAT z;
FLOAT rhw;
DWORD Diffuse;
FLOAT u;
FLOAT v;
};

void Draw2DTex ( c2DTexture *t2DTex, int tPosX, int tPosY )
{
if ( t2DTex == NULL )
{
return;
}
m_2DTexOnShowing = t2DTex;
tPosX += m_2DTexOnShowing->m_ShiftX;
tPosY += m_2DTexOnShowing->m_ShiftY;

m_FinalArray[0].x = (FLOAT)(m_PosX + tPosX);
m_FinalArray[0].y = (FLOAT)(m_PosY + tPosY);
m_FinalArray[1].x = (FLOAT)(m_PosX + tPosX + t2DTex->m_Width);
m_FinalArray[1].y = (FLOAT)(m_PosY + tPosY);
m_FinalArray[2].x = (FLOAT)(m_PosX + tPosX);
m_FinalArray[2].y = (FLOAT)(m_PosY + tPosY + t2DTex->m_Height);
m_FinalArray[3].x = (FLOAT)(m_PosX + tPosX + t2DTex->m_Width);
m_FinalArray[3].y = (FLOAT)(m_PosY + tPosY + t2DTex->m_Height);

if ( m_Flag & DHC_MIRROR_UD )
{
t2DTex->m_stTVB[2].x = m_FinalArray[0].x;
t2DTex->m_stTVB[2].y = m_FinalArray[0].y;
t2DTex->m_stTVB[3].x = m_FinalArray[1].x;
t2DTex->m_stTVB[3].y = m_FinalArray[1].y;
t2DTex->m_stTVB[0].x = m_FinalArray[2].x;
t2DTex->m_stTVB[0].y = m_FinalArray[2].y;
t2DTex->m_stTVB[1].x = m_FinalArray[3].x;
t2DTex->m_stTVB[1].y = m_FinalArray[3].y;
}
else
{
t2DTex->m_stTVB[0].x = m_FinalArray[0].x;
t2DTex->m_stTVB[0].y = m_FinalArray[0].y;
t2DTex->m_stTVB[1].x = m_FinalArray[1].x;
t2DTex->m_stTVB[1].y = m_FinalArray[1].y;
t2DTex->m_stTVB[2].x = m_FinalArray[2].x;
t2DTex->m_stTVB[2].y = m_FinalArray[2].y;
t2DTex->m_stTVB[3].x = m_FinalArray[3].x;
t2DTex->m_stTVB[3].y = m_FinalArray[3].y;
}

D3DCOLOR tmpColor[4];
memcpy ( tmpColor, m_Color, sizeof ( tmpColor ) );
if ( m_Flag & DHC_ALPHA_UP )
{
tmpColor[0] &= 0x00FFFFFF;
tmpColor[1] &= 0x00FFFFFF;
}
else if ( m_Flag & DHC_ALPHA_DOWN )
{
tmpColor[2] &= 0x00FFFFFF;
tmpColor[3] &= 0x00FFFFFF;
}
if ( m_Flag & DHC_ALPHA_LEFT )
{
tmpColor[0] &= 0x00FFFFFF;
tmpColor[2] &= 0x00FFFFFF;
}
else if ( m_Flag & DHC_ALPHA_RIGHT )
{
tmpColor[1] &= 0x00FFFFFF;
tmpColor[3] &= 0x00FFFFFF;
}

t2DTex->m_stTVB[0].Diffuse = tmpColor[0];
t2DTex->m_stTVB[1].Diffuse = tmpColor[1];
t2DTex->m_stTVB[2].Diffuse = tmpColor[2];
t2DTex->m_stTVB[3].Diffuse = tmpColor[3];
m_pD3D9Dev->SetTexture ( 0, t2DTex->m_Texture );
m_pD3D9Dev->DrawPrimitiveUP ( D3DPT_TRIANGLESTRIP, 2, t2DTex->m_stTVB, sizeof ( stCUSTOMVERTEX ) );
}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!