Jump to content
  • Advertisement
Sign in to follow this  
Tangooo

VBO problem

This topic is 3806 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
Advertisement
could it be because you are setting mNOArrayE to 0 when deleting, and using it in glDrawElements call?

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!