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 to multiple windows

  1. #1
    Newbie Newbie
    Join Date
    Jul 2012
    Posts
    1

    Drawing to multiple windows

    Hello! It seems as though information on the net is limited about using multiple contexts/multiple windows. What I'm trying to do is use two contexts to draw scenes to different windows, I think I'm not totally clear on what OpenGL calls are affected by which context is made current. This is the pseudo-code of how I thought it should go:

    Make Current Window 1
    Generate VAO 1
    Bind VAO 1
    Generate VBO 1 for vertices
    Bind VBO 1
    Buffer VBO 1
    Generate VBO 2 for uvs
    Bind VBO 2
    Buffer VBO 2
    Make Current Window 2
    Generate VAO 2
    Bind VAO 2
    Generate VBO 3 for vertices
    Bind VBO 3
    Buffer VBO 3
    Generate VBO 4 for uvs
    Bind VBO 4
    Buffer VBO 4
    Do shader stuff which gets shared
    While True
    Make Current Window 1
    Clear
    Bind VAO 1
    Bind VBO 1
    VertexAttribPointer VBO 1
    Bind VBO 2
    VertexAttribPointer VBO 2
    glDrawArrays
    Make Current Window 2
    Clear
    Bind VAO 2
    Bind VBO 3
    VertexAttribPointer VBO 3
    Bind VBO 4
    VertexAttribPointer VBO 4
    glDrawArrays
    Loop

    But I end up only seeing drawing on one of two windows, if I reverse the order at the top so that the other window is made current at the beginning, then I see drawing on that window. Am I missing something being shared or not shared?

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    393
    From Appendix D of the OpenGL 4.2 core spec:
    Objects that can be shared between contexts include buffer objects, program
    and shader objects, renderbuffer objects, sync objects, and texture objects (except
    for the texture objects named zero).


    Objects which contain references to other objects include framebuffer, program
    pipeline, query, and vertex array objects. Such objects are called container objects
    and are not shared.
    So you can't use the VAOs you generate in the 2nd context, you will need to create new ones for that context.

Posting Permissions

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