multithreading - SDL 2.0: Create window in main thread, but do all rendering in separate one -
this current setup: i'm doing opengl rendering using sdl (currently on linux). initialize sdl (sdl_init
) , create application window (sdl_createwindow
) in main thread , pass second thread. second thread creates opengl context (sdl_gl_createcontext
) , starts render loop, while main thread listens events. think it's important note gl calls confined second thread; of application logic happens there, main thread responsible handling events come in on sdl.
originally did other way around, turns out can't process events in other main thread on osx , windows, switched around compatible 2 in future.
should have concerns not work on osx/windows? on linux, haven't had whatsoever. there's lots of information on internet context sharing , doing gl calls multiple threads, want do opengl in 1 thread not main one. wouldn't continue coding application later find out won't work anywhere else.
i have app runs on mac/ios/windows structured way (all gl in rendering thread), don't use sdl.
i took @ sdl's cocoa_gl_createcontext
(called sdl_gl_createcontext
on os x) , makes calls make main thread set context.
so, if hit problems, try creating gl context in main thread , pass off rendering thread (instead of creating gl context in rendering thread).
Comments
Post a Comment