[SDL] (openGL repaint) thread problem

Johannes Schmidt sdl at myrealbox.com
Wed Aug 8 10:33:01 PDT 2001


On Tuesday 07 August 2001 21:30, Johann Deneux wrote:
> > I have some problems using threads.
> >
> > If I try to do some drawing stuff in a thread created with
> > SDL_CreateThread, the application exits with
> > Fatal signal: Segmentation Fault (SDL Parachute Deployed)
> > Xlib: unexpected async reply (sequence 0x66)!
>
> Your X server does not support multi-threading. You have to do all your
> calls to the Xlib from one single thread. I guess you may even have to use
> only the main thread.

That seems to be reasonable.
I have tried to compile the code under windows( mingw32 ) and it works.
Also, I packed all graphic things into one repaint function and created a
thread out of it. That works, too.

example:
int paintThread(void * data) {
    SDL_SetVideoMode( 320, 240, 32, SDL_OPENGL);

    glViewport(0, 0, 320, 240);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho( 0, 320, 0, 240, -1, 1);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    while(!quitThread) {
        glClear( GL_COLOR_BUFFER_BIT );
        glLoadIdentity();

        glBegin( GL_QUADS );
        glVertex2i(10, 10);
        glVertex2i(10, 100);
        glVertex2i(100, 100);
        glVertex2i(100, 10);
        glEnd();

        SDL_GL_SwapBuffers();
    }
    return -1;
}

But it is a bit unhandy to have all paint things in one thread.

Is this a general problem of X servers or just of mine ( XFree86 4.1 )?
Which X servers are multi-threaded?

Regards,
Johannes




More information about the SDL mailing list