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 2 of 2

Thread: Drawing on multiple windows problem

  1. #1
    Newbie Newbie
    Join Date
    Dec 2017
    Posts
    1

    Drawing on multiple windows problem

    Hello,

    I'm currently facing a problem while rendering the same scene on different windows, with Opengl 4.1.

    I have two windows, and I use wglMakeCurrent() before rendering into each of them.
    I have one VAO, one program pipeline, etc. and I want to share them to draw the same scene on both windows.

    Everything is fine for the first window, but, while rendering to the second window, the call to glBindVertexArray fails (while using the same VAO as for the first window).
    The strangest thing is that, if I create a dummy VAO (by calling glGenVertexArrays) just before rendering - and not using it anymore - the call to glBindVertexArray() that was failing doesn't fail anymore!
    Same problem with glBindProgramPipeline() : if I create a dummy program pipeline and don't use it, glBindProgramPipeline() doesn't fail anymore. And then it's the call to glDrawArrays() that fails.
    This is a very strange behaviour that I can't explain.

    I tried with a rendering context per window (using wglShareLists), and with only one rendering context used by both windows.

    If someone has an explaination to this behaviour, and/or a solution to that problem, I would be very grateful.

    Thanks

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,526
    Quote Originally Posted by flure_popsy View Post
    I'm currently facing a problem while rendering the same scene on different windows, with Opengl 4.1.

    I have two windows, and I use wglMakeCurrent() before rendering into each of them.
    I have one VAO, one program pipeline, etc. and I want to share them to draw the same scene on both windows.
    VAOs and program pipelines are containers, and as such aren't shared between contexts. You have to create a separate VAO or pipeline for each context.

    Quote Originally Posted by flure_popsy View Post
    Everything is fine for the first window, but, while rendering to the second window, the call to glBindVertexArray fails (while using the same VAO as for the first window).
    The strangest thing is that, if I create a dummy VAO (by calling glGenVertexArrays) just before rendering - and not using it anymore - the call to glBindVertexArray() that was failing doesn't fail anymore!
    Same problem with glBindProgramPipeline() : if I create a dummy program pipeline and don't use it, glBindProgramPipeline() doesn't fail anymore. And then it's the call to glDrawArrays() that fails.
    This is a very strange behaviour that I can't explain.
    This is to be expected. The glGen* functions which allocate names will return names which are unique for the context; there's no need for the names to be globally unique. So when you call e.g. glGenVertexArrays() for the second context, the name will be identical to that used for the first context, although it refers to a different object. When you actually try to use the object, the call will fail because the object hasn't been created (the glGen* functions only reserve the name; they don't create the corresponding object).

    Quote Originally Posted by flure_popsy View Post
    I tried with a rendering context per window (using wglShareLists), and with only one rendering context used by both windows.
    The latter should work. At least, you won't have the issue with containers not being shared if you only have one context. There are still other factors (e.g. you can only use a context with a "compatible" HDC, which may be an issue if you have windows on different screens).

Posting Permissions

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