Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Dynamically generating buffers during runtime

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2011
    Posts
    3

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

    Your help is greatly appreciated,
    Chris

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2011
    Posts
    3
    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?
    Last edited by Chris3D; 09-18-2012 at 09:17 AM.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    Quote Originally Posted by Alfonse
    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?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •