View Full Version : Create a Triangle Strip from unordered 2d points.

MrCybin

06-15-2016, 10:35 PM

Hello,

I am attempting to draw a set of points as triangle strip.

To do this, all of the vertices should be in a vertex buffer, and the colours in a colour buffer.

If i use a delaunay triangulation, however, this will not necessarily return a list of triangles that are in an order appropriate for correct rendering.

So, given a std::vector<Point>.

How is it possible to sort these points?

Regards,

Daniel

GClements

06-16-2016, 01:09 AM

A triangle mesh cannot necessarily be represented as a single triangle strip.

And if the points used for the Delaunay triangulation correspond to anything resembling a uniform sampling of a region, it's unlikely that the resulting mesh can be represented as a single triangle strip.

So you basically have two options: glDrawElements(GL_TRIANGLES) or convert the mesh to multiple triangle strips. I'd suggest the former unless there's a compelling reason to use strips (and the only one I can think of is that you're stuck with some existing software which requires strips).

MrCybin

06-16-2016, 01:31 AM

Awesome.

So with GL_Triangles, the points do not need to be in order?

john_connor

06-16-2016, 01:43 AM

Awesome.

So with GL_Triangles, the points do not need to be in order?

with glDrawArrays(GL_TRIANGLES, ...); 3 consecutive points have to build a triangle

0, 1, 2

3, 4, 5,

... etc

mhagain

06-16-2016, 04:22 AM

With glDrawElements the order comes from the indices, but the vertices can be in any order. Obviously it's going to be more efficient if the vertices are in (at least reasonable) triangle order, but it's not a constraint.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.