Sign in to follow this  

Segfault on second pass when using VBO

This topic is 3414 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

Heya all, I'm having a peculiar problem with VBOs. I'm running my code on two computers, my main machine at home w/ GeForce 7800 and my computer at work which has some terrible Intel integrated card. I checked the extensions for the Intel card here and it supposedly does support ARB_VERTEX_BUFFER_OBJECT, and the drivers have been updated to the most recent version. The code runs fine on the Nvidia machine at home... no memory leaks (that I can tell) and silky smooth rendering. At work, however, the program segfaults on the SECOND frame. I can actually see the first frame rendered properly, then -poof- it dies the second time around. It seems to crap out on glDrawArrays(). The debugger points to the driver library (ig4icd32.dll) when it segfaults. I'm at a loss as to what could be causing this, so I present my code to you all for perusal :) Allocating buffers:
     glGenBuffers(1,&vbo_cube_vertex);
     glGenBuffers(1,&vbo_cube_color);
     glGenBuffers(1,&vbo_cube_normal);

Initialization (done only ONCE):
        printf("buffering data to VBO... ");
        glBindBuffer(GL_ARRAY_BUFFER, vbo_cube_vertex);
        glBufferData( GL_ARRAY_BUFFER, i_quad_count*12*sizeof(GLfloat), va_vertex, GL_STATIC_DRAW );

        glBindBuffer(GL_ARRAY_BUFFER,vbo_cube_color);
        glBufferData( GL_ARRAY_BUFFER, i_quad_count*16*sizeof(GLfloat), va_color, GL_STATIC_DRAW );

        glBindBuffer(GL_ARRAY_BUFFER,vbo_cube_normal);
        glBufferData( GL_ARRAY_BUFFER, i_quad_count*12*sizeof(GLfloat), va_normal, GL_STATIC_DRAW );

        // bind with 0, so, switch back to normal pointer operation
        glBindBuffer(GL_ARRAY_BUFFER, 0);
        printf("done\n");

Rendering:
           glEnableClientState(GL_VERTEX_ARRAY);
           glEnableClientState(GL_NORMAL_ARRAY);
           glEnableClientState(GL_COLOR_ARRAY);

               glBindBuffer(GL_ARRAY_BUFFER, vbo_cube_vertex);         
                glVertexPointer(3, GL_FLOAT, 0, 0);

               glBindBuffer(GL_ARRAY_BUFFER, vbo_cube_normal);         
                glNormalPointer(GL_FLOAT, 0, 0);

               glBindBuffer(GL_ARRAY_BUFFER, vbo_cube_color);         
                glColorPointer(4, GL_FLOAT, 0, 0);

             glDrawArrays(GL_QUADS, 0, i_quad_count*4);

               glBindBuffer(GL_ARRAY_BUFFER, 0);

           glDisableClientState(GL_VERTEX_ARRAY);
           glDisableClientState(GL_COLOR_ARRAY);
           glDisableClientState(GL_NORMAL_ARRAY);

Share this post


Link to post
Share on other sites

This topic is 3414 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this