Sign in to follow this  
ApolloCay

D3DX Line Pattern (stipple)

Recommended Posts

ApolloCay    122
I was reading the DirectX C++ docs and it says that D3DX supports single-pixel-wide antialiased lines and that Line patterns are no longer supported. Yet I see functions for the ID3DXLine interface called SetGLLines, SetPattern and SetPatternScale. If line patterns are no longer supported, how can I draw a line using a stipple or pattern effect like a dash line? I want to use it for my selection tool.

Share this post


Link to post
Share on other sites
turnpast    1011
I could be wrong here, but I believe that ID3DXLine uses textured triangles to do its business. Have you tried using it to do what your want? When you use a line strip or line list you are limited to one pixel with no patterns, but I think that the ID3DXLine stuff works just fine.

Share this post


Link to post
Share on other sites
S1CA    1418
turnpast is correct, ID3DXLine is indeed implemented using polygons; I'd definately suggest trying it.

The lines referred to when the docs talk about line patterns no longer being supported are line primitives, i.e. D3DPT_LINELIST and D3DPT_LINESTRIP.

The problem with D3DPT_LINELIST and D3DPT_LINESTRIP is graphics hardware/driver support for them has always been extremely inconsistent e.g. some hardware supports textures on lines, some doesn't; some hardware supports Gouraud shaded lines, others doesn't; some drivers emulate lines using polygons, etc

Most games don't use line primitives, which is why driver and/or hardware support from IHVs has been bad. AFAIK most games that do have lines use polygons with textures for lines (just like ID3DXLine does) because of the extra flexibility; because single pixel width lines look ugly; and because of the poor hardware support for D3D line primitives (if you're targetting a wide range of gaming graphics cards, all you can guarantee is single pixel width, untextured, unpatterned, unshaded/single colour lines without any anti-aliasing).

Share this post


Link to post
Share on other sites
ApolloCay    122
Thanks for replying, I really appreciate it.

So ID3DXLine is drawn using something like D3DPT_TRIANGLELIST, D3DPT_TRIANGLESTRIP, D3DPT_TRIANGLEFAN to draw its textured polygons that look like lines? How is it that ID3DXLine is able to create the dash line effect? Is that a texture that sits on top of the polygon, were the empty spaces are some sort of alpha color (if you know what I mean)? Or is each separate segment of the dash line it's own polygon? Just trying to figure out how it works.

Sorry for being so ignorant on the subject, but I couldn't find anything on google or in the DirectX docs and the search doesn't appear to be working on the forum.

Share this post


Link to post
Share on other sites
S1CA    1418
ID3DXLine actually uses an alpha-only texture and alpha blending or alpha test to achieve the stipple pattern.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this