When I use glGenBuffers to create a VBO with a pointer to it, I (think) am allocating memory. Subsequent calls to glGenBuffers should return different pointes, but what about the memory previously allocated? In the Nehe examples I didn’t see a “free memory” call… and I read that openGL is kind of a “state machine”, does this mean that if my initializeBuffers() function is called several times I don’t need to free anything and just use the glGenBuffers “as it is” ?
Share
For any
glGenBufferscall you do, you have to do a correspondingglDeleteBufferscall.Note that the pointer you pass to
glGenBuffersis not allocated/deallocated. In fact, it could even be these calls do not actually allocate anything in cpu memory, but you have no guarantee of that either.What you pass to
glGenBuffersis an already-allocated array (or single value) that will store the “name” you reference a gpu-resource by, the workflow looks like this:The reason
bufferis passed as a pointer is because you can create multiple buffers, e.g. like this:Of course,
buffercould very well be dynamically allocated by you, e.g.: