tests/cuda3.2/tests/oceanFFT/oceanFFT.cpp
void createMeshIndexBuffer(GLuint *id, int w, int h)
{
    int size = ((w*2)+2)*(h-1)*sizeof(GLuint);

    // create index buffer
    glGenBuffersARB(1, id);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *id);
    glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER, size, 0, GL_STATIC_DRAW);

    // fill with indices for rendering mesh as triangle strips
    GLuint *indices = (GLuint *) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
    if (!indices) {
        return;
    }

    for(int y=0; y<h-1; y++) {
        for(int x=0; x<w; x++) {
            *indices++ = y*w+x;
            *indices++ = (y+1)*w+x;
        }
        // start new strip with degenerate triangle
        *indices++ = (y+1)*w+(w-1);
        *indices++ = (y+1)*w;
    }

    glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
// create index buffer for rendering quad mesh
create index buffer for rendering quad mesh
create index buffer for rendering quad mesh
void createMeshIndexBuffer(GLuint *id, int w, int h)
{
    int size = ((w*2)+2)*(h-1)*sizeof(GLuint);
    glGenBuffersARB(1, id);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *id);
    glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER, size, 0, GL_STATIC_DRAW);
    GLuint *indices = (GLuint *) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
    if (!indices) {
        return;
    }
    for(int y=0; y<h-1; y++) {
        for(int x=0; x<w; x++) {
            *indices++ = y*w+x;
            *indices++ = (y+1)*w+x;
        }
        *indices++ = (y+1)*w+(w-1);
        *indices++ = (y+1)*w;
    }
    glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void createMeshIndexBuffer ( GLuint * id , int w , int h ) { int size = ( ( w * 2 ) + 2 ) * ( h - 1 ) * sizeof ( GLuint ) ; glGenBuffersARB ( 1 , id ) ; glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , * id ) ; glBufferDataARB ( GL_ELEMENT_ARRAY_BUFFER , size , 0 , GL_STATIC_DRAW ) ; GLuint * indices = ( GLuint * ) glMapBuffer ( GL_ELEMENT_ARRAY_BUFFER , GL_WRITE_ONLY ) ; if ( ! indices ) { return ; } for ( int y = 0 ; y < h - 1 ; y ++ ) { for ( int x = 0 ; x < w ; x ++ ) { * indices ++ = y * w + x ; * indices ++ = ( y + 1 ) * w + x ; } * indices ++ = ( y + 1 ) * w + ( w - 1 ) ; * indices ++ = ( y + 1 ) * w ; } glUnmapBuffer ( GL_ELEMENT_ARRAY_BUFFER ) ; glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , 0 ) ; }
create index buffer for rendering quad mesh
create index buffer for rendering quad mesh
// create index buffer // fill with indices for rendering mesh as triangle strips // start new strip with degenerate triangle