2d in directx

i need to make a 2d waypoint editor, and now that directdraw is not part of managed directx and gdi+ is so slow... how do i draw things like lines and circles



Answer this question

2d in directx

  • Tim Stall

     The ZMan wrote:
    Circles

    - draw lots of short lines along the path sin(angle), cos(angle) where angle loops from 0 to 360 degrees. The number of steps gives you how smooth it will be.


    I would personally recommend this method - there are a lot of quite simple algorithms out there for generating the coordinates of a triangle (I find polar coordinates to be quite friendly). However, if you do take this route it pays to generate a single "unit circle" during load time, and where applicable resize the circles using matrix-maths...

    It'd be a performance hit if you generated a vertex buffer with such an algorithm for every single circle you draw Smile

    This article shows a lot of the basics of what you want to do, the syntax will have changed slightly (the article is 2yrs old), but the concepts are the same.

    hth
    Jack



  • Emilio A. S.

    Lines - use the D3DX line class see http://forums.microsoft.com/msdn/ShowPost.aspx PostID=116629

    Circles
    - draw lots of short lines along the path sin(angle), cos(angle) where angle loops from 0 to 360 degrees. The number of steps gives you how smooth it will be.
    - or draw a circle into a bitmap and then use that bitmap as a texture using the D3D sprite class. However if you change the size of the circle it will zoom the bitmap which may not be what you are looking for. If your texture is the biggest you want. See the October SDK for a sprite sample.

    If the waypoint editor is standalone (rather than within a DX game screen) then you could use GDI.



  • 2d in directx