how would I restart a triangle strip?

I’m using a VBO to store my terrain data and displaying it using triangle strips. The problem I have it that it seems to be drawing extra triangles connecting each row to the next column down. I think a easy solution would be to just have it restart the triangle strip at each of the columns.

This is how I fill my VBOs data for displaying. heights is just a vector<vector<float>> that holds columns and rows of heights that I load from a grayscale image. I would just need a way to restart a triangle strip after each time the second for loop finishes.

for(int z = 0; z < heights.size()-1; z++)
	{
		for(int x = 0; x < heights[0].size()-1; x++)
		{
			vec.push_back(x * tileSize);
			vec.push_back(heights[x][z] * maxHeight);
			vec.push_back(z * tileSize);

			vec.push_back(x * tileSize);
			vec.push_back(heights[x][z+1] * maxHeight);
			vec.push_back(z+1 * tileSize);
		}
            //add a new triangle strip here
	}

[QUOTE=Exempt;1253941]I’m using a VBO to store my terrain data and displaying it using triangle strips. The problem I have it that it seems to be drawing extra triangles connecting each row to the next column down. I think a easy solution would be to just have it restart the triangle strip at each of the columns.
[/QUOTE]
With glDrawArrays(), you’d need one call for each row. With glDrawElements(), you can either use GL_TRIANGLES rather than GL_TRIANGLE_STRIP, or use glPrimitiveRestartIndex() (requires OpenGL 3.1).

Please do use the functionality, but do not use the function. Setting index to non-default is a bad idea. Just glEnable(GL_PRIMITIVE_RESTART) or better glEnable(GL_PRIMITIVE_RESTRAT_FIXED_INDEX) (if you have it).

Setting index to non-default is a bad idea.

Says who? Do you have any evidence for this? On what hardware is it “a bad idea?”

I ended up using glDrawElements and a index… seems like a better idea in the end to me.

Anecdotal. But i know of at least one GL implementation that does not support the feature ‘natively’.
Shouldn’t really be much of surprise given how DX specified restart index.