Sign in to follow this  
asishnr@gmail.com

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

Recommended Posts

Hi there,

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

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

[b][size="3"]1.[/size][/b] I have to draw lines with different [b]thickness [/b]and different [b]color[/b]. I found it difficult to implement it using primitive drawing (using PrimitiveType.LineList).

[u]My code looks as follows.[/u]

[b] [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct PositionColored
{
public Vector3 Position;
public int Color;
public Vector3 Normal;
public static readonly VertexFormat format = VertexFormat.Diffuse | VertexFormat.Position | VertexFormat.Normal;
}

[u]In reder method:-[/u]

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

_Device.Present();[/b]

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. [b]So thickness and color are the problems I am facing here.
[/b]
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?



[b][size="3"]2[/size][/b]. 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'.
[u]
Code is given below.[/u]
[b]
SlimDX.Direct3D9.Line _Line = null;
[i] _Line.GLLines = true;
_Line.Width = 0.5;[/i]

_Device.BeginScene();
[i]
_Line.Draw(_Vertices, this._RenderColor);[/i]

_Device.EndScene();
_Device.Present();[/b]



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

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