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

Thread: GLUT/OpenGL with threads - Having problems

  1. #1

    GLUT/OpenGL with threads - Having problems

    Hi folks,

    I'm having a small problem with threads and GLUT/OpenGL under Linux.
    I'm not really sure this is allowed or not, mayby someone can help me.

    My program starts and later I decide to make a new thread. This thread
    then makes all GLUT calls to create window and assign callbacks.
    At various points in that threads execution, the program terminates
    with an XIO error 0 (success).
    Sometimes it works longer, until I press the mouse button, press a key,
    or something, and sometimes just directly during initialization.

    Is there anything one must do to activate the current thread as the context
    or so. I'm pretty sure my main thread is not doing any X, GLUT or OpenGL
    stuff.

    Anyone with any clue?

  2. #2
    Guest

    Re: GLUT/OpenGL with threads - Having problems

    I do not think GLUT is supporting multiple threads. I do not see why your code should not work but it is probably better to use SDL or other some library that has multiple thread support.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,749

    Re: GLUT/OpenGL with threads - Having problems

    what i remember is that glut has some functions to create sub-windows. This may be the way it uses threads. i don't know very well.

  4. #4

    Re: GLUT/OpenGL with threads - Having problems

    Hi guys,

    thanks for your support. However, the problem really was as follows.

    libpthreads have something like (or exactly) __init_ctors_.... which
    is normally run when you load a library (for global C++ objects).
    Earlier versions of Xlib wasn't compiled with threads-support, it
    appears to be thread safe now. But there I picked up the reason.
    errno is altered by pthreads such that each thread have a unique
    instance.
    Since my GLUT and OpenGL stuff was in a DSO I loaded dynamically
    (a plugin) and my main application (loading the DSO) didn't link with
    pthreads. I now link with pthread and it works, it might possibly also
    work if I execute the __init_ctors function of the loaded libraries.

    Worth noting though, when I run my app from gdb, I see no output,
    my GL-drawable remains black and graphics is drawn.

    / Patric

Posting Permissions

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