Sign in to follow this  

RECT with decimals?

This topic is 3295 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

I was trying to animate a sprite but realized that a RECT takes only LONG values not decimal ones, I need decimal values for the sprite frames to display properly but since the sprite->Draw function needs a RECT I don't know what to do. Does anyone knows a way to fix/around this? Here's the code just in case.
void render()
{
    d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

    d3dDevice->BeginScene(); 

    d3dSprite->Begin(NULL);  

	D3DXVECTOR2 pos = D3DXVECTOR2(128,128);
	D3DXVECTOR2 scale(2.0f,2.0f);
	D3DXMATRIX mat;

	D3DXMatrixTransformation2D(&mat, NULL, 0.0, &scale, NULL, 0, &pos);
	rct.left = 39*chrono.frame;
	rct.right = rct.left+39;
	rct.top = 39 *chrono.row;
	rct.bottom = rct.top+39;

	d3dSprite->SetTransform(&mat);

    d3dSprite->Draw(sprite, &rct, NULL, NULL, 0xFFFFFFFF);

    d3dSprite->End(); 

    d3dDevice->EndScene(); 

    d3dDevice->Present(NULL, NULL, NULL, NULL);

    return;
}

Thanks

Share this post


Link to post
Share on other sites
I think you'd have to stop using the ID3DXSprite and draw your sprite yourself using a vertex buffer containing two triangles. Then you'd be free to specify whatever texture coordinates as (0-1) range floats you wanted.

I'm not sure if it is the same issue as you have (or even if it has been fixed in ID3DXSprite since the article was written) but there's an article here on GameDev that discusses some of the texturing issues using the sprite interface.

Share this post


Link to post
Share on other sites
Quote:
Original post by Crazyfool
I am not sure why you would need decimals in the rect?

The rect tells the sprite what texel portion to draw from the texture.

In typical situations, that's true. But it is possible to set texture coordinates in-between pixels, and it's useful in some situations. For example, you could animate a scrolling waterfall more smoothly if the drawing source coordinates can smoothly transition between pixels.

I'm not sure about the OP's case, though.

Share this post


Link to post
Share on other sites

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

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