XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Drawing Text properly

Last post 04-20-2008 12:07 PM by ArenAzul. 4 replies.
  • 04-19-2008 10:07 AM

    Drawing Text properly

    Which is the best way to draw a texture in the screen without any kind of distortion?

    That is with it's real size and with no filtering.

    I ask because i'm experiencing weird problems and i have no idea about how to solve them. I suppose they come because i use floats to set the size and position of the squares in the shader, but.... anyway, texture coordinates for tex2D are floats too, so that shouldn't be a problem, should it?

    Of course, filtering is off everywhere, and i guess the textures are loaded correctly.

    I would apreciate any idea even if it's looks simple or obvious cause maybe it helps me in some way.

    Thanks.

  • 04-20-2008 12:57 AM In reply to

    Re: Drawing Text properly

    Answer

    If you use ID3DXSprite you can blit a texture straight to the screen. If you give it's Draw() method a NULL rectangle it'll draw the whole texture to the screen. If you want to stick the texture to vertices then you can try using transformed coordinates, using D3DFVF_XYZRHW instead of D3DFVF_XYZ, which basically works with screen coordinates rather than some world type unit, so you can base the vertices to the width/height of the texture.

    Personally I'd just blit it with a sprite, all you have to do is supply the screen position you want it drawn at.

  • 04-20-2008 6:43 AM In reply to

    Re: Drawing Text properly

    Ok... but which option is faster? I only want to draw text.

    (anyone interested in this thread may also see this other one: http://forums.xna.com/thread/58000.aspx)

  • 04-20-2008 9:43 AM In reply to

    Re: Drawing Text properly

    I doubt you'll notice too much of a difference speed wise. The sprite will set up the texture coordinates for you. In your other thread you mention point sprites, they use one vertex so that'll be the least amount processing involved out of all three methods. But in the end I wouldn't worry, four vertices is nothing, you can process those quicker than the machine can print them, when you have a good few thousand vertices to process then you can start worrying.
  • 04-20-2008 12:07 PM In reply to

    Re: Drawing Text properly

    Thank you very much. You solved all my problems ^^

Page 1 of 1 (5 items) Previous Next