Direct2D Transform

Posted by James on Game Development See other posts from Game Development or by James
Published on 2012-03-29T21:22:01Z Indexed on 2012/03/29 23:42 UTC
Read the original article Hit count: 308

Filed under:

I have a beginner question about Direct2D transforms. I have a 20 x 10 bitmap that I would like to draw in different orientations.

To start, I would like to draw it vertically with a destination rectangle of say:

(left, top, right, bottom)
(300, 300, 310, 320)

The bitmap is wider than it is tall (20 x 10), but when I draw it vertically, it will be appear taller than it is wide (10 x 20).

I know that I can use a rotation matrix like so:

m_pRenderTarget->SetTransform(
    D2D1::Matrix3x2F::Rotation(
        90.0f,
        D2D1::Point2F(<center of shape>))
    );

But when I use this method to rotate my shape, the destination rectangle is still wider than it is tall. Maybe it would look something like this:

(left, top, right, bottom)
(280, 290, 300, 300)

The destination rectangle is 20 x 10 but the bitmap appears on the screen as 10 x 20. I can't look at the destination rectangle in the debugger and compare it to:

(left, top, right, bottom)
(300, 300, 310, 320)

Is there any simple way to say "I want to rotate it so that the image is rendered to exactly this destination rectangle after the rotation?" In this case, I would like to say "Please rotate the bitmap so that it appears on the screen at this location:"

(left, top, right, bottom)
(300, 300, 310, 320)

If I can't do that, is there any way to find out the 10 x 20 destination rectangle where the bitmap is actually being rendered to the screen?

© Game Development or respective owner

Related posts about rotation