Skip to main content
gamedev.net
🔒 Locked

Line Pattern Property

Started by arri 8 replies 1.2k views
Original Post
arri
arri
Hi, do anybody have experience in setting the linePattern renderstate in DX8? I don't know how to set it in vb6! It's little tricky, because the linePattern is not a simple value, it's a type: Type D3DLINEPATTERN LinePattern As Integer RepeatFactor As Integer End Type How can I set it by using only a LONG-Value which is supported by the setRenderState function? Thanks for any suggestions! ARRI
arri
arri
Still the linePattern problem above, do somebody know the property and know how to set it with setrenderState?
digital_phantom
digital_phantom
From what I see,
RepeatFactor and LinePattern are Integers (both 16-bit (2-bytes) each.)

And the value to pass to SetRenderState() is a Long, so since a Long is 32-bit (4-bytes) I figure you can easilly combine RepeatFactor and LinePattern together.

I could be wrong, but there is no other information to go by. You don't even see any sample code on the net.

I tried to write some code to do what I explained but I don't know how exactly how this is suppose to affect rendering. And another thing what I don't know to do is convert the bits into an Integer for the LinePattern.
arri
arri
What I want to do is, draw dashed and doted lines with drawPrimitive. And I think, that's what it's supposed to affect.

I found some "integer"-values in the net for the bit-Pattern:

52428: 1100110011001100 to produce a dotted line.
43690: 1010101010101010 to produce a point line.
61166: 1110111011101110 to produce a dashed line.

that are the values, if you calc the bits into a number, but the interger wents from -32.768 to 32.767, so I thought that it might work if substract 32768 from for example 52428 and I've got my Linepattern integer value.

And then I toke the hex of that LinePattern and of a repeatfactor and made a long:

clng("&H" & Hex(LinePattern) & hex(repeatfactor))

I also tried hex(repeatfactor) in the front, still no affect!
And at least I tried to set the renderstate by using the pointer to the Type:

Type D3DLINEPATTERN
LinePattern As Integer
RepeatFactor As Integer
End Type

And it didn't work again! I don't know any other methods, slowly but surely I think this is a dead property, seriously! :-)

Greets
Armin
Cygon
Cygon
Maybe this will help you, creates a long from two integers:

Public Property Get MakeLong(ByVal iHi As Integer, ByVal iLo As Integer) As Long    MakeLong = (CLng(iHi) * &H10000) Or (iLo And &HFFFF&)End Property


Hard to believe, but it's actual unit tested production code and won't cause any overflows, regardless of the numbers you feed it ;)

-Markus-
Professional C++ and .NET developer trying to break into indie game development.
Follow my progress: http://blog.nuclex-games.com/ or Twitter - Topics: Ogre3D, Blender, game architecture tips & code snippets.
digital_phantom
digital_phantom
I've tried my luck with all this new information.

I created a function to handle the line pattern:

Public Function D3D8Util_LinePatternToLong(Desc As D3DLINEPATTERN) As Long
On Error Resume Next

D3D8Util_LinePatternToLong = (CLng(Desc.LinePattern) * &H10000) Or (Desc.RepeatFactor And &HFFFF&)
End Function

And I tested it out by setting the renderstate right before drawing some axis lines, but nothing looked any different.
I've noticed that no one knows anything about this "LinePattern" thing. Maybe it's some made up thing Microsoft put in. lol.
arri
arri
I found out that there is a device cap called RasterCaps and its sub cap D3DPRASTERCAPS_PAT determines whether the line pattern property is supported by the device. And in my case it turned out, it actually not. What a waste of time!

So, now I try to find another way how to draw dashed and dotted line. And first I thought of doing it with textures. That mean I want to create a texture with 2 colors maybe black and white, and then tell directx which one I want to render transparent. So far so good, but the thing is I'm really new in directx, so do somebody know if something like this is realizable? That means: can I apply a texture on a line drawed with drawPrimitive?

- Armin -
digital_phantom
digital_phantom
I don't really think you can do that.
But, you can if you have a ploygon drawed normally but instead set the draw mode to wireframe. Because on my projects I noticed when I did that the lines are drawed, but yet the textures on top of those lines are still to, so you could do that.

Topic Locked

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

Sign in to reply to this topic.