I'm not seeing a function for this, but is there a easy way to draw text sideways, (rotated 90 degrees) is there a trick to doing it?
]]>Something like this should work:
al_identity_transform(&t); al_rotate_transform(&t, pi / 2); al_use_transform(&t); al_draw_text(...);
]]>
Do you mean draw the text vertically or actually turn it on its side?
]]>Turn it on it's side. I would use the example above, but what on earth is t pointing at?
]]>EDIT
Oh I get you. t is an ALLEGRO_TRANSFORM*.
T doesn't point at anything, it's a transform, not a vector. He sets up the transform to rotate around the origin by 90 degrees clockwise and then uses the transform before drawing the text. You'll probably want to center your text before you rotate it though.
ALLEGRO_TRANSFORM t; al_identity_transform(&t); al_translate_transform(&t , -xpos , -ypos); al_rotate_transform(&t , M_PI/2.0f); al_translate_transform(&t , xpos , ypos); al_use_transform(&t); al_draw_text(font , al_map_rgb(255,255,255) , xpos , ypos , ALLEGRO_ALIGN_CENTER , my_string);
]]>
I'm not at my main system right now, but does that transform the whole drawing surface. As in, if I was to paste bitmaps or draw primitives, they will also be transformed as well until I reset the use_transform();
]]>The transforms that you 'use' affect the current bitmap target only. But if that is the backbuffer, then it affects all drawing.
]]>I guess the question is, how do you set it back to normal after the text print. There doesn't seem to be a "clear" command and I have other non-rotated things being drawn to my target bitmap. (I admit my matrix math is a little weak so I don't know what an "identity" is)
]]>I think its in the manual.
http://liballeg.org/a5docs/trunk/transformations.html#al_use_transform
Call this function with an identity transformation to return to the default behaviour.
However, to reset the projection transform is a little different. But you didn't alter that, so no worries.
]]>int GraphicsContext::drawRotatedText( const std::string& text,agui::Font* font,const agui::Color& color, int x, int y, float deg, int flags ) { int fx = font->getTextWidth(text) / 2; int fy = font->getLineHeight() / 2; m_transform.identity(); m_transform.translate(-fx,-fy); m_transform.rotate(deg); m_transform.translate(x,y); useTransform(m_transform); drawText(text,font,color,0,0,flags); resetTransform(); return fx * 2; }