Imagine having a 4x4 square, with 16 smaller squares inside of it, with associated data on what t开发者_运维问答he 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?
I am not sure I understand correctly the geometry you try to render. If it is a kind of grid here is how I would do it:
Create and fill a Vertex Buffer Object with all your vertices:
8--9--a--b
| /| /| /|
|/ |/ |/ |
4--5--6--7
| /| /| /|
|/ |/ |/ |
0--1--2--3
Create and fill an Element Array Buffer with the indices used to render your quad grid:
{ 0,1,5,4, 1,2,6,5, 2,3,7,6, 4,5,9,8, 5,6,a,9, 6,7,b,a }
Setup everything using gl*Pointer, use glDrawElements with GL_QUADS to render that. The vertex cache will handle the already transformed vertices: every quad after the first one will only require to transform 2 vertices.
I don't think you will gain anything if you tri-strip or quad-strip it, except some memory on the Element Array Buffer.
If you want to strip it, create the corresponding Element Array Buffer, and call glDrawElements for each line. This can be done in one call using the Nvidia only extension GL_NV_primitive_restart
If it isn't a grid, you can give a try to NvTriStrip.
精彩评论