Jump to content
  • Advertisement
Sign in to follow this  
WuTz

Translation isn't working (Sprites) [DX10]

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

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!