Sign in to follow this  
Eralp

Sprite sizes

Recommended Posts

Hi, this question could also go to "for beginners" section but whatever.. I am creating my guisystem(so far I have started good ^^) and I wrote my draw functions etc. about my "buttons".Then I wanted to make them sizable(coded sizes, not in runtime),however I realiazed that I have nowhere to put a RECT variable that holds screen coords which the sprite will be stretched to.I know how to scale but as far as I know I can only scale by the multiple of 2.(though its logical when I think) So what can I do to get my sprite drawn stretched exactly where I want it to :S and you know I don't want all my buttons to be in the same size or by 2 multiplied size :).

Share this post


Link to post
Share on other sites
I am drawing my sprites like this;


void Button::Draw(LPD3DXSPRITE &d3dspt,LPD3DXFONT &dxfont)
{
D3DXVECTOR3 center(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 position(X, Y, 0.0f);
d3dspt->Draw(sprite, NULL, &center,&position, D3DCOLOR_ARGB(200, 255, 255, 255));
}



my loading function is ;


void LoadTexture(LPDIRECT3DTEXTURE9* texture, LPCTSTR filename)
{
D3DXCreateTextureFromFileEx(d3ddev, filename, D3DX_DEFAULT, D3DX_DEFAULT,
D3DX_DEFAULT, NULL, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT,
D3DX_DEFAULT, D3DCOLOR_XRGB(255, 0, 255), NULL, NULL, texture);
return;
}

Share this post


Link to post
Share on other sites
You can use ID3DXSprite::SetTransform to set a transformation matrix to draw with. This will affect the size of the sprite, as well as the position. If you pass a scaling matrix, you can scale a sprite to an arbitrary size.

Keep in mind, however, that the position is scaled as well, so you'll have to scale the position by the inverse amount before drawing, so that after it gets scaled it is exactly where you intended it to be.

Share this post


Link to post
Share on other sites
Yayy I got it now, I'm familiar with matrixes since I was doing 3 d programming before but I thought you could only scale it by multiple of 2 when you use SPRITES.sorry for taking your time, but thanks though :)

Share this post


Link to post
Share on other sites

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