Dynamically generating buffers during runtime

Hi folks,

is there a workaround for using glGenBuffersARB/glGenBuffers and such calls while rendering? I know they only work in the initialization before the first render call. Is there a command to halt the rendering, so I can call these functions? Or a similar trick?

Background: I'm trying to create textures at runtime, because my app is receiving those textures from an external source, the number of textures is not known and may change during runtime while other stuff is being drawn.

is there a workaround for using glGenBuffersARB/glGenBuffers and such calls while rendering? I know they only work in the initialization before the first render call.

Says who? There's no limitation on when you can generate objects. Though generally you should avoid doing so for performance reasons in the middle of your render loop, there is no reason why you can't.

If you're having problems with this, that's likely due to either an incredibly buggy driver or user error.

I never had success calling glGenTextures(1, &m_textureID); in the rendering loop or from another thread, it would not set the value m_textureID.. I doubt its the driver, so it must be me.. any suggestions?

Though generally you should avoid doing so for performance reasons in the middle of your render loop[..]

Chris3D: To work around this, you could simply implement some observer-like approach. For instance, pass a callback to the external source (if you can) which will only be invoked if there are actual changes to the amount of textures etc. Threading issues are, of course, to be dealt with as well. Another solution would be to poll the external source to see if there are actual changes to be considered in the rendering loop before doing texture related work.

As usual: Any GL errors when calling glGenTextures()? Care to share some code?