Problem with display lists, threads, and device/rendering contexts

Problem with display lists, threads, and device/rendering contexts

Post by Ali Lakhi » Thu, 06 Mar 2003 04:43:47



Hi,

I am doing something similar to what Alan Garny is doing (subj: "Rendering
both within a thread and directly..."). That is, I have two threads, one
rendering window. The main thread renders objects. The second thread creates
display lists (DLs) for the main thread. That is, the two threads need to
share the DLs.

However, I can't even create the rendering context, let alone share the
display lists. So, I thought I would ask for help from the OpenGL community.

I tried using two variations: wglMakeCurrent() as well as
wglCreateContext(). Details are below:

    // Global variables
    HDC    hdc;
    HGLRC  hglrc;

    // Main thread
    hglrc = wglGetCurrentContext();
    DWORD d = GetLastError();           /* No error */
    hdc = wglGetCurrentDC();
    d = GetLastError();                 /* No error */
    hThread = CreateThread(NULL, 0, IdleThread, NULL, 0, &dwThreadId);

    // Idle thread function
    DWORD WINAPI IdleThread(LPVOID pParam)
    {
        bool b = wglMakeCurrent(hdc, hglrc); /* bool b is false */
        d = GetLastError();       /* Error code is 6: The handle is invalid */

        // other stuff [snip]

        // Create display list
        glNewList(DLnum, GL_COMPILE);  /* DLnum is 0 */
    }

I get error code 6 which indicates that the handle is invalid. I'm not sure
why the handle would be invalid because I get the handle from the main thread.
If I try to create a new context, I get the same errors as well:

    // Idle thread function
    DWORD WINAPI IdleThread(LPVOID pParam)
    {
        HGLRC hglrc1 = wglCreateContext(hdc); /* ghlrc1 is NULL */
        DWORD d = GetLastError(); /* Error code is 6: The handle is invalid */

        // other stuff [snip]
    }

Thanks in advance for your time and consideration. Best regards,

-Ali

 
 
 

1. Creating a display device rendering context under Win32?

Hi,  I'm fairly new to Win32 & am trying to use the wgl extensions.  It
looks like it should be possible to create a device context for the display
(using CreateDC()) & attach an OpenGL rendering context to that (bypassing
all the Windows yuck).  Does that sound right, & if so where would I find
the details?

Thanks for any advice,
-Jim C.
----------------------
Jim Crowell
Division of Biology
216-76
Caltech
Pasadena, CA
(818) 395-8337

2. new DTP Domain portal review: your opinion please

3. Sharing display lists between rendering contexts (wglShareLists)???

4. OT Auto-fx plugins

5. RIVA TNT, Display lists, rendering contexts and OpenGL

6. freeware gs sgi image bug

7. Sharing display lists between different rendering contexts ?

8. Asking about Mac and Linux

9. Display List useage in multiple Rendering Context

10. OpenGL display lists and rendering contexts

11. Multi-Threading and Rendering Context on SGI Workstation

12. Can I have more than one OpenGL rendering contexts for a thread (only one current)

13. Rendering OpenGL graphics on a printer device context under Windows