Jump to content
  • Advertisement
Sign in to follow this  

[SlimDX] 2D Line drawing with color and line thickness - URGENT... PLZ HELP

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

Hi there,

I am using SlimDX with C# to develop my 2D chart. Due to our client's recommendation I am using 'SlimDX.Direct3D9'.

I have a simple requirement. I am using Primitive drawing to draw the lines. But I found following issues.

1. I have to draw lines with different thickness and different color. I found it difficult to implement it using primitive drawing (using PrimitiveType.LineList).

My code looks as follows.

public struct PositionColored
public Vector3 Position;
public int Color;
public Vector3 Normal;
public static readonly VertexFormat format = VertexFormat.Diffuse | VertexFormat.Position | VertexFormat.Normal;

In reder method:-

_Device.VertexFormat = PositionColored.format;
_Device.DrawUserPrimitives<PositionColored>(primitiveType, 0, vertices.Length / 2, vertices);


I found few examples with rendering using triangle type. But in my case I should be able to provide a color at run time in which i can draw lines. So thickness and color are the problems I am facing here.

Now, when i finished drawing, all the lines are rendered in same color (Black -> despite i specify the color as Red) and with unique thickness. Can any one please help?

2. I tried with an alternate approach by using the Line object. I could give a specific color and thickness also. But unfortunately I can only draw cannected lines (just like in 'LineStrip' . But I want the functionality like 'LineList'.

Code is given below.

SlimDX.Direct3D9.Line _Line = null;
_Line.GLLines = true;
_Line.Width = 0.5;


_Line.Draw(_Vertices, this._RenderColor);


If some one can help to solve out any of these 2 scenarios, it would be a great help. Please advise, thanks in advance.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!