# Fixing triangle strip output

## Recommended Posts

relpats_eht    138
Im working on a height map render using draw arrays and triangle strips. Im starting out just by making all the output work by brute force (no geoMipmapping or culling yet), but I cant seem to get the triangle strips quite right. I always end up with a long triange from one edge to the other per each colum (or row depending how you look at it) here is the code that renders the vertices
int index = 0;
for(int w=0; w<(width-1); w++){
for(int h=0; h<(height-1); h++){
if(w==0){
mapData[index] = w - (width/2.0f);
mapData[index+1] = (buffer[int(w+(h*width))]/255.0f)*50.0f;
mapData[index+2] = h - (height/2.0f);

mapData[index+3] = (w+1) - (width/2.0f);
mapData[index+4] = (buffer[int((w+1)+(h*width))]/255.0f)*50.0f;
mapData[index+5] = h - (height/2.0f);

index+=6;
}

mapData[index] = (w+1) - (width/2.0f);
mapData[index+1] = (buffer[int((w+1)+((h+1)*width))]/255.0f)*50.0f;
mapData[index+2] = (h+1) - (height/2.0f);

mapData[index+3] = w - (width/2.0f);
mapData[index+4] = (buffer[int(w+((h+1)*width))]/255.0f)*50.0f;
mapData[index+5] = (h+1) - (height/2.0f);

index+=6;
}
}


and here is the code that outputs the terrain
for(int i=0; i<(height-1); i++){
glDrawArrays(GL_TRIANGLE_STRIP, ((2*height)+2)*i, (2*height)+2);
}

(yeah, I know the codes awful, but its only temporary untill I move on to better rendering techniques) Would anyone be so kind as to point out what I need to change in order to remove the extra triangles? Screen Shot

Enigma    1410

Enigma

##### Share on other sites
relpats_eht    138

eh... I suppose it would be best to just go back to regular triangles.