0
\$\begingroup\$

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

glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_DYNAMIC_DRAW);

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.

\$\endgroup\$
2
  • \$\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\$
    – House
    Commented Dec 30, 2013 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
    Commented Dec 30, 2013 at 20:50

1 Answer 1

1
\$\begingroup\$

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).

\$\endgroup\$
5
  • \$\begingroup\$ Good answer, but this is not what I am looking for. \$\endgroup\$
    – BWG
    Commented Dec 30, 2013 at 20:53
  • \$\begingroup\$ @BWG You should ask a better question then. \$\endgroup\$
    – RandyGaul
    Commented Dec 30, 2013 at 20:53
  • \$\begingroup\$ You are right I should. I am sorry for being misleading. \$\endgroup\$
    – BWG
    Commented Dec 30, 2013 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
    Commented Dec 30, 2013 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
    Commented Dec 30, 2013 at 21:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .