Rotating Text

Started by
4 comments, last by Evil Steve 13 years, 4 months ago
Hello,

How can i obtain the font sprite's dimensions I use to render D3DX fonts?

d3dxFontSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE);
d3dxFont->DrawText(d3dxFontSprite, str.c_str(), -1, &rct, 0, getD3DColor(color));
d3dxFontSprite->End();

My goal is to rotate the text about the sprite's center instead of the world origin.

Thanks.
Advertisement
There is DT_CALCRECT flag, it'll fill your RECT structure with coordinates.
How can I use the RECT structure after the draw call and text is already rendered?

What I want to do is to be able to rotate text around it's center instead of the origin (0, 0)

Thanks.
You want:
RECT rct;rct.left = rct.top = rct.right = rct.bottom = 0;d3dxFont->DrawText(NULL, str.c_str(), -1, &rct, DT_CALCRECT, 0);
Then it's too late to make use of the returned rc to figure out the correct transformation for the already drawn text ;)

If you use DT_CALCRECT, the text isn't drawn, but the rectangle is updated.

This topic is closed to new replies.

Advertisement