Sign in to follow this  

Translation isn't working (Sprites) [DX10]

This topic is 2848 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 trouble with Translating my sprites. No matter what vaules I pass in, the sprite stays at the middle of the screen! Here is my rendering function:
void WUIButton::Render(ID3DX10Sprite* Sprite,D3DXVECTOR2* ScreenSize)
{
	D3DX10_SPRITE spriteInfo;

	D3DXVECTOR2 ScaleFix;

	

	ScaleFix.x=(float)((float)1/((float)ScreenSize->x/2))*ButtonImg.ActiveTexture->Info.Width;  //Fix the Scale-bug.
	ScaleFix.y=(float)((float)1/((float)ScreenSize->y/2))*ButtonImg.ActiveTexture->Info.Height;

	ScaleFix.x*=Scale.x; //Apply original Sprite-Scale
	ScaleFix.y*=Scale.y;

	D3DXVECTOR2 rp; //Render Pos

	rp=Position; //Original Position

	rp.x/=ScaleFix.x; //Apply Scale
	rp.y/=ScaleFix.y;


	POINT cp;
	GetCursorPos(&cp);

	rp.x+=cp.x; //Apply some values. For testing!
	rp.y+=cp.y;

    D3DXMatrixTranslation(&spriteInfo.matWorld, rp.x, rp.y, 1.0f); //Translate (Not working!?)
	D3DXMatrixScaling(&spriteInfo.matWorld,ScaleFix.x,ScaleFix.y,0); //Scale works!
	
	
    spriteInfo.TexCoord = D3DXVECTOR2(0, 0); //Fill the Structure
    spriteInfo.TexSize = D3DXVECTOR2(1, 1);
    spriteInfo.ColorModulate = D3DXCOLOR(1, 1, 1, 1);
	spriteInfo.pTexture = ButtonImg.ActiveTexture->Tex;
    spriteInfo.TextureIndex = 0;
    Sprite->DrawSpritesBuffered(&spriteInfo, 1); //Draw
}

Any Ideas?

Share this post


Link to post
Share on other sites

This topic is 2848 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this