Correct me if I am wrong, but if you call "glBufferData(...)" upon an existing buffer, it will resize the buffer to whatever data you upload.

Does that mean if I call something like


it will keep the buffer in existence, but it will have size and no data?

In the description of glBufferData, it says it is acceptable to pass NULL as a data parameter, but it mentions nothing of the size parameter.

  • \$\begingroup\$ What do you mean by "acceptable"? Seems like it would be easy to test if it's possible. Though I'm not sure why you'd want to do this. \$\endgroup\$ – MichaelHouse Dec 30 '13 at 20:45
  • \$\begingroup\$ I want to do this for beacause A: when I assign actual data, I don't call genBuffers, B: I don't have needless data sitting on the GPU. I doubt it would break anything if I called it, but it may do something I malign which am unaware of, which is why I ask. \$\endgroup\$ – BWG Dec 30 '13 at 20:50

I have only seen this done with buffer orphaning. The idea is to manually map your buffer for use, this way as a user you know which portions of your buffer have been written and commit to the OpenGL driver. Once you run out of memory on your buffer you call glBufferData with a NULL parameter.

This tells OpenGL to find a new contiguous memory chunk to use. You need to pass in your desired size of this new buffer, so your example with zero is (I think) not what you want.

The reason to do this is to allow for asynchronous writing. With this method you can just send data to the GPU over and over without caring about if the previously mapped buffer sections are still locked or not (still being read by the driver).

  • \$\begingroup\$ Good answer, but this is not what I am looking for. \$\endgroup\$ – BWG Dec 30 '13 at 20:53
  • \$\begingroup\$ @BWG You should ask a better question then. \$\endgroup\$ – RandyGaul Dec 30 '13 at 20:53
  • \$\begingroup\$ You are right I should. I am sorry for being misleading. \$\endgroup\$ – BWG Dec 30 '13 at 20:54
  • \$\begingroup\$ @BWG It's okay, just try to be very specific about what you want. This will help people give answers to what you want. You can edit your original question. \$\endgroup\$ – RandyGaul Dec 30 '13 at 20:55
  • \$\begingroup\$ In retrospect, it is probably not the most necessary question I could have asked. I am sorry for asking a stupid question. \$\endgroup\$ – BWG Dec 30 '13 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.