# Is there an efficient, available online, algorithm for converting a matrix of squares into a triangle strip?

Imagine having a 4x4 square, with 16 smaller squares inside of it, with associated data on what the squares should look like (ie., opacity, colour, etc...).

Is there an existing, efficient, algorithm, for converting this set of squares into an open-gl compatible triangle strip?

-

Firstly, I'd suggest that if your primitives (the squares) have different appearances, especially opacity, then tri-stripping may not make sense (i.e. the vertices aren't really shared).

Secondly, these days you're probably better off with indexed geometry, rather than an actual tri-strip, so consider going that route.

Finally, if you really want to generate a tri-strip, have a look at nvtristrip, which is available from nVidia:

NVTriStrip

(indeed, it will also generate efficient indexed lists, so look at it regardless).

-
Based on my current, probably flawed, understanding of opengl graphics, opacity is a property that's applied to the middle of a shape rather than its vertices. Is this false? Is there a tutorial or document where I can better learn this stuff? – blueberryfields Oct 19 '10 at 16:22
Opacity is controlled via alpha-blending. Supply a value for the alpha can be done through vertices, through texturing, or using shaders (or a combination). Which is best for you depends exactly on what you're doing. – JasonD Oct 19 '10 at 16:33

This is a trivial problem if you are able/willing to link strips with degenerate triangles - as most stripping algorithms do anyway.

Each Nx1 row of squares is a very simple triangle strip. For each row, you want to start a new strip.

Simply duplicate the last vertex of strip 1 and the first vertex of strip 2, and that will create a degenerate polygon linking the two strips

(However, if as your question indicates, the vertices are not shared between the squares - different colours/UVs etc, then you don't want to use strips)

-