• 11
• 9
• 10
• 9
• 10

# Buffer failing to generate value

This topic is 997 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

If i use
GLuint buffer(0);
glGenBuffers(1, &buffer);
and it fails does it change the value of buffer? This feels like something i should know

##### Share on other sites

glGenBuffers changes the value of buffer. After the call buffer holds the ID of the generated buffer.

I don't see any reason why this should fail here.

How do you see it fails? An have you tried to read the OpenGL error message for more information?

##### Share on other sites
Practically speaking it can only fail if your context is not set on the current thread.
If it fails, buffer will be 0 in your case (either because it set it to 0 or because it didn’t change it from 0).
I believe it does change it to 0, but if you need to know it is easy to test by removing the context from the thread and defaulting your value to 10101010.

L. Spiro Edited by L. Spiro

Thanks L. Spiro

##### Share on other sites

Practically speaking it can only fail if your context is not set on the current thread.

QFT.

As far as I can tell, the standard doesn't consider it possible forglGenBuffers() to fail. All it does is return the next N unused integers in a sequence, after all.

The only context in which I could see that function legitimately failing, is if the system is if the call overflows the stack, or you have exhausted the heap, in either of which case you have far larger problems...