Fastest way to draw rectangles with slimdx / sharpdx

Started by
11 comments, last by EduardoMoura 11 years, 4 months ago

[quote name='Yura' timestamp='1355409031' post='5010229']
Is it possible to draw rectangles, not triangles? There is not rectangles in PrimitiveType enum...


You make a rectangle from triangles, 2 triangles make one square / rectangle, unless you mean using quads?

I noticed you were using 8 points for a rectangle too, which would make sense if you were using linelist, eitherway with triangles you would only need 6 points (4 if indexed). You can always convert single points to quads (rectangles) using the geometry shader, which is probably better for what you want doing

How are you learning DirectX btw?
[/quote]

I can triangulate any 3D surface, so, as a result of triangulation I receive list of elements. Each element consists of 3-8 points, but mostly it has 4 or 8 points, because it is triangulation with quadrangular elements. You are right, I'm using line list do draw each element, so, if it has 4 points, I must put in VertexBuffer 8 points, to draw it completely. It's a bit excessive, but I don't know how to make it another way and it works nice.
[source lang="csharp"]List<Vertex> points = new List<Vertex>();
for (int i = 0; i < elements.Length; i++)
{
List<Node> list = elements.Nodes;

int listCount = list.Count;
for (int j = 0; j < listCount - 1; j++)
{
points.Add(new Vertex() { Color = SharpDX.Color.Red, Position = new Vector4(list[j].X, list[j].Y, list[j].Z, 1.0f) });
points.Add(new Vertex() { Color = SharpDX.Color.Red, Position = new Vector4(list[j + 1].X, list[j + 1].Y, list[j + 1].Z, 1.0f) });
}
points.Add(new Vertex()
{
Color = SharpDX.Color.Red,
Position = new Vector4(list[listCount - 1].X, list[listCount - 1].Y,
list[listCount - 1].Z, 1.0f) });
points.Add(new Vertex() { Color = SharpDX.Color.Red, Position = new Vector4(list[0].X, list[0].Y, list[0].Z, 1.0f) });
}[/source]

Look at this links, I'll show what I have:
this is lines http://imageshack.us/photo/my-images/194/capturerse.png/
this is triangles http://imageshack.us/photo/my-images/51/capture3be.png/
and this is what I need http://imageshack.us/photo/my-images/546/capture2pu.png/
Quads must be filled with some colour, but must have visible lines. I'm not sure it is possible to make with triangle list.

About DirectX, I'm learning it directly from the internet: forums, code examples etc. I do not read any thick books, if you asking about it)
Thanks for losing your time on me)
Advertisement
Another problem is that triangles have invisible sides ( look here http://imageshack.us/photo/my-images/51/capture3be.png/ )
When I rotate a shape I can only see her front side.. Triangles that are backwards to me invisible
Because you probably have back culling enable you can only see the frontal face of the triangles, check where you are creating your device for back culling (I am no sure where it is set in DirectX, but I am pretty sure it is somewhere in the device creation)

Check out my new blog: Morphexe

This topic is closed to new replies.

Advertisement