• Advertisement
Sign in to follow this  

Translation isn't working (Sprites) [DX10]

This topic is 2946 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.x*=Scale.x; //Apply original Sprite-Scale

	D3DXVECTOR2 rp; //Render Pos

	rp=Position; //Original Position

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

	POINT cp;

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

    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
Sign in to follow this  

  • Advertisement