Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 3049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post

Link to post
Share on other sites
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)


'get top-left position
Dim pos As Vector2D
pos.X = p.X - (_width * 0.5F * scale)
pos.Y = p.Y - (_height * 0.5F * scale)

_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 Sub

Share this post

Link to post
Share on other sites
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!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!