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

Thread: rendering to multiple windows

  1. #1
    Junior Member Newbie bytebucket's Avatar
    Join Date
    Dec 2008
    Location
    Eastern PA, USA
    Posts
    23

    rendering to multiple windows

    I'm trying to render to multiple windows. Each window has its own rendering context which is set before any rendering operations are done on the individual window.

    This works fine on my desktop. When I tried running it on my laptop, I found that when I opened the second window, the rendering in the first window went crazy (I know not very specific, hard to describe whats happening).

    Anyway, just wanted to ask here and see if there are any specific things to keep in mind when rendering to multiple windows, aside from the obvious one of making a separate context and setting each window's context before rendering, which I'm already doing.

  2. #2
    Junior Member Newbie bytebucket's Avatar
    Join Date
    Dec 2008
    Location
    Eastern PA, USA
    Posts
    23

    Re: rendering to multiple windows

    well, no sooner did I post than I found the problem

    I was using a class for 2D text rendering which loaded fonts and created textures. These were cached. Problem is, the cache was used from both windows and both contexts. So it was trying to use a texture from one context in another.

    The cache needs to be on a per-context basis.

  3. #3
    Junior Member Newbie bytebucket's Avatar
    Join Date
    Dec 2008
    Location
    Eastern PA, USA
    Posts
    23

    Re: rendering to multiple windows

    another thing to keep in mind if you're using multiple rendering contexts. if you're using HW accelerated GL, you can't share resources (display lists, textures) between rendering contexts, so each context needs its own. but, when you do your cleanup for a context (deleting display lists, textures, etc) that context must be active while you're doing this.

    - set context active
    - delete resources
    - set no active context
    - delete context

    If you're not careful about the order you can end up freeing resources (or trying to) from the wrong context.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    669

    Re: rendering to multiple windows

    Quote Originally Posted by bytebucket
    if you're using HW accelerated GL, you can't share resources (display lists, textures) between rendering contexts, so each context needs its own.
    That is a completely false statement. How did you get that idea?
    I'm trying to render to multiple windows. Each window has its own rendering context which is set before any rendering operations are done on the individual window.
    My suggestion to this is: spare yourself the hassle and just use one rendering context for all windows. In Windows' terms this means using one HGLRC for all your HDC's.

  5. #5
    Intern Contributor
    Join Date
    Oct 2008
    Posts
    86

    Re: rendering to multiple windows

    See wglShareLists.

  6. #6
    Junior Member Newbie bytebucket's Avatar
    Join Date
    Dec 2008
    Location
    Eastern PA, USA
    Posts
    23

    Re: rendering to multiple windows

    sorry for the confusion, I think I spoke too quickly there and without enough precision.

    We used to do SW rendering only. We used wglShareLists and it worked well. We could share resources between the screen context and the printer context and an offscreen bitmap context as examples.

    We then switched to HW accelerated rendering for the on-screen display. When we did this, we found that sharing resources between the hardware accelerated context for the screen with the context for the printer, for example, didn't work.

    From the MSDN docs for wglShareLists:

    ... However, not all rendering contexts in a process can share display lists. Rendering contexts can share display lists only if they use the same implementation of OpenGL functions. All client rendering contexts of a given pixel format can always share display lists ...
    So because of this, we moved from just sharing everything to using per-context storage so that we could more generally use multiple contexts.

    I believe you're correct in that, in this case, since both contexts are the same implementation (both on screen HW accelerated rendering) we could probably use wglShareLists and it would work here.

    My point was just that using the resources across contexts was what was causing the problem (as you pointed out probably because we're not calling wglShareLists).

    So calling wglShareLists would be one solution for these two contexts, or using a single context for screen rendering.

Posting Permissions

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