Jump to content
  • Advertisement
Sign in to follow this  
macmoy

distorted image HELP

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

what causes this distortion?

I dont use LPD3DXSPRITE.
I made my Sprite class.




D3DSURFACE_DESC desc;
m_Tex->GetLevelDesc(0, &desc);



m_Width = (float)m_Rect.right - (float)m_Rect.left;
m_Height = (float)m_Rect.bottom - (float)m_Rect.top;

float neg_width;
float width;

neg_width = (-(float)m_Width/2.0f);
width = (float)m_Width/2.0f;

float neg_height;
float height;

neg_height = (-(float)m_Height/2.0f);
height = (float)m_Height/2.0f;



vertices[0].position = D3DXVECTOR3( (float)neg_width, (float)height, 0.0f );
vertices[1].position = D3DXVECTOR3( (float)width, (float)height, 0.0f );
vertices[2].position = D3DXVECTOR3( (float)neg_width, (float)neg_height, 0.0f );
vertices[3].position = D3DXVECTOR3( (float)width, (float)neg_height, 0.0f );


vertices[0].color = D3DCOLOR_ARGB( m_Alpha, 255, 255, 255 );
vertices[1].color = D3DCOLOR_ARGB( m_Alpha, 255, 255, 255 );
vertices[2].color = D3DCOLOR_ARGB( m_Alpha, 255, 255, 255 );
vertices[3].color = D3DCOLOR_ARGB( m_Alpha, 255, 255, 255 );

int tot_width = desc.Width;
int tot_height = desc.Height;



float val_x = (float)m_Rect.left / (float)tot_width;
float val_y = (float)m_Rect.top / (float)tot_height;
vertices[0].tu = val_x; vertices[0].tv = val_y;

val_x = (float)((float)m_Rect.left + m_Width) / (float)tot_width;
val_y = (float)m_Rect.top / (float)tot_height;
vertices[1].tu = val_x; vertices[1].tv = val_y;

val_x = (float)m_Rect.left / (float)tot_width;
val_y = (float)((float)m_Rect.top + m_Height) / (float)tot_height;
vertices[2].tu = val_x; vertices[2].tv = val_y;

val_x = (float)((float)m_Rect.left + m_Width) / (float)tot_width;
val_y = (float)((float)m_Rect.top + m_Height) / (float)tot_height;
vertices[3].tu = val_x; vertices[3].tv = val_y;






HRESULT res;
res = Device::getInstance()->getDevice()->CreateVertexBuffer( 4*sizeof(CUSTOMVERTEX), 0 /*Usage*/, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &m_Vb, NULL );

if ( FAILED( res ) )
{
MSGBOX( "Vertex Buffer Creation Failed!", "CreateVertexBuffer()" )
}

void *p_verts;

m_Vb->Lock( 0, sizeof(vertices), (void**)&p_verts, 0 );


memcpy( p_verts, vertices, sizeof(vertices) );

m_Vb->Unlock();

m_pVert = (CUSTOMVERTEX*)p_verts;




NOTE: that is a single image.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!