Skip to main content
GameDev.net gamedev.net
🔒 Locked

Drawing line wider than 1px with DirectX

Started by Roxypinky Apr 19, 2010 at 8:27 PM 5 replies 2.7k views
Original Post
Roxypinky
Roxypinky
Hello everyone! I need to draw anti aliased lines (straight and curve) that are wider than 1 pixel. I can't find anything on that online, all I have found is limited to 1 pixel wide. I realize Direct3D doesn't support drawing lines natively but I'm sure it's doable. Thanks in advance! -Roxy
Hodgman
Hodgman
In your software, take the line segments that you want to draw, and use that information to construct a strip of quads of the desired thickness.
e.g. given the line-segments in the center, you need to construct the quads surrounding them:
        ________       /\_______|      / /\______|     / / /     / / /     \/ /      \/ 
ouraqt
ouraqt
I would suggest drawing polygons that are more than 1px wide.

A thick line is really just a rectangle. Plus, if you have anti-aliasing on in general, it should give you anti-aliased lines, too, when they are composed of polygons.

Additionally, I believe you can send it line data (2 points) and have the geometry shader form the polygons you need.

What version of Direct3D are you using?

Edit: Aw, beat me to it.
gekko
gekko
You can use ID3DXLine if you don't want to do this yourself.
-- gekko
Roxypinky
Roxypinky
I'm using D3D9. I guess rectangles would be perfect for straight lines but I'm not certain it would give the best results for curves unless maybe it have lots of polygons. As for ID3DXLine, I believe it only supports 1px wide lines. Wouldn't it be possible to draw my lines to an offscreen texture. But then I would have to handle everything from plotting the line and curves to antialiasing :S But I somehow feel it would give me a better result (provided I implement everything correctly). I'll probably just use polygons for now but does anyone could point me to some good info on how to draw efficiently to offscreen textures?

Thanks for the replies!
-Roxy
Roxypinky
Roxypinky
Alright, ID3DXLine should be good enough for now but I'll need to look into it a bit more to draw curves. I won't need curves for now so it can wait.

Thanks :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.