[SDL] (openGL repaint) thread problem

Johannes Schmidt sdl at myrealbox.com
Sat Aug 11 05:39:00 PDT 2001


On Friday 10 August 2001 16:25, you wrote:
> Johann Deneux <johannd at DoCS.UU.SE> wrote:
> >I know for sure using threads with the Xlib is in general dangerous. That
> >means using anything that uses the Xlib is trickt too: Qt, gtk, OpenGL,
> >SDL...
>
> Xlib is thread-safe if you follow the rules in the Xlib docs, and you
> may call Xlib functions from different threads if you are careful.
> SDL is not thread-safe in that respect, so never use the SDL API from
> any other thread than the main thread. (Also avoid SDL functions in
> callbacks.)

Ok, a special repaint thread isn´t that necessary.

But my program crashes with every call to any openGL function
( I don´t think glGetString calls Xlib functions and I think this thread
should be thread-safe ).

example code:
#include "SDL/SDL.h"
#include "SDL/SDL_thread.h"

#include "GL/gl.h"

int my_thread( void * data ) {
    glGetString( GL_VERSION );
}

int main( int argc, char * argv[] ) {
    SDL_Init(SDL_INIT_VIDEO);
    SDL_SetVideoMode( 320, 240, 32, SDL_OPENGL);

    SDL_Thread * test = SDL_CreateThread(my_thread, NULL);

    SDL_WaitThread(test, NULL);

    SDL_Quit();

    return 0;
}


I don´t know why this code should seg fault.
( or is it a problem of my openGL driver?)

Regards,
Johannes




More information about the SDL mailing list