Skip to main content
GameDev.net gamedev.net
🔒 Locked

scaling sprites

Started by localrob2 Sep 23, 2005 at 5:21 PM 1 replies 350+ views
Original Post
localrob2
localrob2
Using directX9.0 and ID3DXSprite How can I scale sprites? Make them larger or smaller, without changing the actual bitmap file. this is the draw function HRESULT Draw( LPDIRECT3DTEXTURE9 pTexture, CONST RECT *pSrcRect, CONST D3DXVECTOR3 *pCenter, CONST D3DXVECTOR3 *pPosition, D3DCOLOR Color ); The old draw function had a scaling vector. Anyone have any suggestions?
Evil Steve
Evil Steve
You can use the SetTransform() function to set a scaling transform. Something like this (untested):
D3DXMATRIX matView, matProj, matScale, matFinal;pDevice->GetTransform(D3DTS_VIEW,&matView);pDevice->GetTransform(D3DTS_PROJECTION,&matProj);D3DXMatrixScaling(&matScale,2.0f,0.5f,1.0f);matFinal = matScale*matView*matProj;pSprite->SetTransform(&matFinal);pSprite->Draw(...);
That should scale by 2.0 in X and 0.5 in Y. Z isn't used, so you'll usually want to set it to 1.0.
And you need the view and projection matrices, because SetTransform() wants a matrix to translate from world space to screen space, not from model space to world space (which you'd just set matScale for).
localrob2
localrob2
thanks, I'll try that

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.