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: Threads and OpenGL

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    12

    Threads and OpenGL

    I have a really simple need for threads in my application (WIN32):
    Open a window from the main application -> Render a scene in that window.
    I'd like to support multiple windows. Unfortunately, I see no simple way of doing this without using a separate thread per window - particularly being that each thread can have at most ONE rendering context. Has anybody out there done this before? I'm really pressed for time so some good, detailed info - or better yet source code - would really help.
    Also, I've read "when using multiple threads the modified message pump (using PeekMessage) should be replaced with the usual GetMessage/TranslateMessage combination." Could someone explain this? We're talking about the message pump in the main application ( or associated with the spawned window ), right?
    Thanks for the help.
    Cheers!
    ks

  2. #2
    Intern Newbie
    Join Date
    Oct 2002
    Location
    Rijeka, Croatia
    Posts
    36

    Re: Threads and OpenGL

    Rendering contexts are similar to device context. That means that each window with a handle has a DC, that also means that each window can be rendered separately.

    Use glMakeCurrent(handle, RC) to set current
    rendering context for OpenGL engine. Mind this: there is only one engine. CURRENT RC
    defines the output of the engine.

    So:

    glMakeCurrent (handle, RC1);
    // draw in window 1
    glMakeCurrent (handle, RC2);
    // draw in window 2;
    etc...

Posting Permissions

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