[SlimDX] Sprite projection matrix for drawing font [SOLVED]
Hi
I am rendering to a backbuffer that is different in size to the screen, and I use a projection matrix to keep the perspective.
When I try drawing fonts with a sprite though, it just doesn't work, and they appear all bunched up.
I apply a world matrix to the sprite before rendering the font, and i tried multiplying the projection matrix into there but it didnt work.
Can someone please help me out?
[Edited by - BoxyCraft on May 20, 2010 11:22:00 PM]
This is basically the draw function, in Visual Basic. This works fine if the rendertarget and screen are the same size.
Public Sub Draw(ByRef p As Vector2D, ByVal scale As Single) 'Begin _sprite.Begin(SpriteFlags.AlphaBlend) 'get top-left position Dim pos As Vector2D pos.X = p.X - (_width * 0.5F * scale) pos.Y = p.Y - (_height * 0.5F * scale) 'Transform _sprite.Transform = Matrix.Identity * Matrix.Scaling(scale, scale, 1) * Matrix.Translation(pos.X, pos.Y, 0) 'Draw text rect.X = _spacing rect.Y = _spacing rect.Width = _width - _spacing - _spacing _smallfont.MeasureString(_sprite, _text, DrawTextFormat.Left, rect) _smallfont.DrawString(_sprite, _text, rect, DrawTextFormat.Left, _textcolor.ToArgb) 'End _sprite.Flush() _sprite.End() End Sub
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement