Jump to content
  • Advertisement
Sign in to follow this  
smek2

Drawing lines in Direct3D

This topic is 4885 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

Ok, i'm able to draw lines using the DrawPrimitive(D3DPT_LINESTRIP) function. But is there a way to simply adjust the width of the line? I don't really want to use that ID3DXLine Interface, though. It looks nasty.

Share this post


Link to post
Share on other sites
Advertisement
I might be wrong, since I use DirectX 8.1, not 9.0, but I have the documentation for both and this doesn't seem to have changed in 9.0: there doesn't seem to be a way to set the width for lines drawn as line strips or lists using the DrawPrimitive() functions. I would go ahead and use ID3DXLine. I took a look at it and it looks pretty painless and straightforward. You'll probably want to write a wrapper for it, of course, but that can be pretty thin. I don't think you have any other option, unless you want to essentially reproduce the functionality of ID3DXLine yourself using quads, but I don't see what you would gain that way.

Share this post


Link to post
Share on other sites
I had same problem a while ago, I wanted to be able to adjust the width of the lines, but it seems that there is no way with directx to do that, and I think that Id3dxLine is 2d only, of course you can do some trick to make it fake 3d, but it will have no perspectives (get smaller as line gets far).
so I might be wrong about this, but the only way is to create a cylinder of desirable width and length, and then adjust the world matrix to orient the cylinder as you want.
if you don't know how to create a cylinder, there are functions within directx that do this for you.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dark Metamorphosis
I had same problem a while ago, I wanted to be able to adjust the width of the lines, but it seems that there is no way with directx to do that, and I think that Id3dxLine is 2d only, of course you can do some trick to make it fake 3d, but it will have no perspectives (get smaller as line gets far).
so I might be wrong about this, but the only way is to create a cylinder of desirable width and length, and then adjust the world matrix to orient the cylinder as you want.
if you don't know how to create a cylinder, there are functions within directx that do this for you.


ID3DXLine has a method called SetWidth().

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by smek2
Ok, i'm able to draw lines using the DrawPrimitive(D3DPT_LINESTRIP) function.
But is there a way to simply adjust the width of the line?
I don't really want to use that ID3DXLine Interface, though. It looks nasty.


Most consumer PC graphics hardware doesn't support variable width lines, which is why Direct3D line primitives don't support variable width lines.

Additionally, hardware support for textures, and even shading on lines is pretty bad.

In fact, a number of consumer cards don't actually support lines at all - they're emulated using polygons.

Because of bad line support in hardware, most people usually draw a quad out of two triangles to achieve variable width textured lines. This is what ID3DXLine does internally.

Because most people don't use line primitives in shipping code, hardware support for them remains bad.


So really your choices are:

1) Use ID3DXLine, at least as a prototype.

2) Write your own thick line emulation using quads; TBH code wise, your own implementation isn't going to be too different from the code inside ID3DXLine.

3) Emulate thick lines by using a bunch of thin lines - beware, the artifacts you'll see probably won't be acceptable.

4) Pursuade the hardware vendors to improve line support in their consumer parts (line support in CAD cards is pretty good) - and then persuade MS to change the API to support them - unless you're making a killer app that will sell more graphics cards and your surname is Carmack, it's unlikely to be a high priority though, the graphics card vendors are more likely to emulate thick lines in their drivers - which brings us back to ID3DXLine [wink]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!