[SlimDX] Sprite projection matrix for drawing font [SOLVED]

Started by
2 comments, last by BoxyCraft 14 years, 1 month ago
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]
Advertisement
Post your code.
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
Solved. I was changing the state before the Sprite.Flush! [depressed]

I even cut that part out before posting my code, because I didn't think it was important!

Anyway, solved, and no problem!
[imwithstupid]

This topic is closed to new replies.

Advertisement