Jump to content
  • Advertisement
Sign in to follow this  

Fixing triangle strip output

This topic is 4764 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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++){
            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);
        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);

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!