Yes, CreateContext implicitly does a MakeCurrent - but you can just make it current on another thread afterwards. I don’t think there’s any reason you can’t CreateContext on another thread, though.
- J?rgen.________________________________
From: sdl-bounces@lists.libsdl.org [sdl-bounces at lists.libsdl.org] on behalf of Jonas Kulla [nyocurio at gmail.com]
Sent: Wednesday, July 31, 2013 1:59 PM
To: SDL Development List
Subject: Re: [SDL] Rendering in thread other than main
2013/7/31 Jorgen Tjerno <@Jorgen_Tjernomailto:Jorgen_Tjerno>
If you want to stick with C, you could look at using the “blocks” extension from clang: http://clang.llvm.org/docs/BlockLanguageSpec.html
That way you can pass code directly.
From: sdl-bounces@lists.libsdl.org<mailto:sdl-bounces at lists.libsdl.org> [sdl-bounces at lists.libsdl.org<mailto:sdl-bounces at lists.libsdl.org>] on behalf of john skaller [skaller at users.sourceforge.net<mailto:skaller at users.sourceforge.net>]
Sent: Wednesday, July 31, 2013 4:44 AM
To: SDL Development List
Subject: Re: [SDL] Rendering in thread other than main
On 31/07/2013, at 9:58 AM, Jonas Kulla wrote:
So, you mean doing both event handling and rendering on the main thread,
any anything else in a separate thread?
This would make things reeeeally complicated as I’d basically have to
reinvent GLX to pass my render commands to the main thread =(
It’s only complicated if you use a low level language like C.
Er… I feel like there was a misunderstanding. The part about "reimplementing GLX"
was a joke to illustrate how ridiculous of an effort it would be for a problem that probably
does not even exist. I’m sticking to threads.
This OSX manual [1] doesn’t mention anywhere that OpenGL rendering is restricted
to only the main thread. I’m not too interested in Windows, but I couldn’t find anything
contrary to my design either. In fact, this blog post [2] says it’s just fine as long as I
get a DC from the main thread window (which I hope SDL does under the hood for me
with SDL_GL_CreateContext).
So I just have a last question: Does SDL_GL_CreateContext implicitly call
SDL_GL_MakeCurrent?
Thanks everyone who tried to help me so far =D
[1] https://developer.apple.com/library/mac/#documentation/graphicsimaging/conceptual/opengl-macprogguide/opengl_threading/opengl_threading.html
[2] http://hacksoflife.blogspot.de/2008/02/creating-opengl-objects-in-second.html
Jonas