Sign in to follow this  

VBO problem

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

HI all, I have problem with VBO. When I delete data from system memory ( after creating VBO - so data should be in VRAM ) the contents of VBO doesn't render. When I leave data in system memory everything is fine,and VBO render correctly. My code: creating VBO:
glGenBuffersARB(1, &mV1BufID);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mV1BufID);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, mNOArrayE*sizeof(vertex_coord), mVArray, GL_STATIC_READ);

glGenBuffersARB(1, &mV2BufID);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mV2BufID);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, mNOArrayE*sizeof(vertex_coord), mVArray2, GL_STATIC_READ);

glGenBuffersARB(1, &mTBufID);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mTBufID);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, mNOArrayE*sizeof(texture_coord), mTArray, GL_STATIC_READ);

glGenBuffersARB(1, &mIBufID);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mIBufID);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mNOArrayE*sizeof(unsigned int), mIdxArray, GL_STATIC_READ);


Delete memory ( after creating VBO ):
if ( mNOArrayE != 0 )
{
    if ( mVArray != NULL )         delete [] mVArray;
    if ( mVArray2 != NULL )     delete [] mVArray2;
    if ( mTArray != NULL )         delete [] mTArray;
    if ( mIdxArray != NULL )    delete [] mIdxArray;

    mNOArrayE = 0;
}


render VBO:
glColor3f(1.0f, 1.0f, 1.0f);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1f);
   
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glBindTexture(GL_TEXTURE_2D, mTexTable[0]);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mV1BufID);
glVertexPointer(3, GL_FLOAT, 0, NULL);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mTBufID);
glTexCoordPointer(3, GL_FLOAT, 0, NULL);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mIBufID);
glDrawElements(GL_QUADS, mNOArrayE, GL_UNSIGNED_INT, NULL);

glBindTexture(GL_TEXTURE_2D, mTexTable[1]);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mV2BufID);
glVertexPointer(3, GL_FLOAT, 0, NULL);
glDrawElements(GL_QUADS, mNOArrayE, GL_UNSIGNED_INT,NULL);

glBindBuffer(GL_ARRAY_BUFFER_ARB, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0);

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_ALPHA_TEST);


after creating VBO and befor delete memory I check for VBOs
if ( glIsBuffer(mV1BufID) )    std::cout<< "VB 1 OK" << std::endl;
if ( glIsBuffer(mV2BufID) )    std::cout<< "VB 2 OK" << std::endl;
if ( glIsBuffer(mTBufID) )     std::cout<< "VBT OK" << std::endl;
if ( glIsBuffer(mIBufID) )     std::cout<< "VBI OK" << std::endl;


and everything is ok. Why VBOs doesn't render if I delete memory ??

Share this post


Link to post
Share on other sites

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