Jump to content
  • Advertisement
Sign in to follow this  
Eralp

Sprite sizes

This topic is 3788 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, 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
Advertisement
You can scale by whatever you want when you're rendering, quads can have any arbitrary size and position. How exactly are you rendering your sprites?

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
What you might want to do is instead of specifying a position in ID3DXSprite::Draw is to use D3DXMatrixTransformation2D to create a single transform matrix for your positioning and scaling.

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
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!