0
votes

I'm using SDL2 and OpenGL 3.3, and wondering if following situations are thread safe:

case 1

  1. There are multiple threads and each of them has a context and a SDL window.
  2. Those threads render geometries multi-threaded.

case 2

  1. There are multiple threads and each of them has a SDL window. But there's only one context that is shared.
  2. Those threads render geometries multi-threaded.

I guess latter case is not safe because threads change current context by calling 'SDL_GL_MakeCurrent', but I'm not sure.

1
yes you're rightzoly01

1 Answers

0
votes

Ok I was silly.

I was reading documents and found it:

SDL_GL_GetCurrentContext: Use this function to get the currently active OpenGL context. SDL_GLContext SDL_GL_GetCurrentContext(void)

And realized that there's only one OpenGL context activated, which means without calling 'SDL_GL_MakeCurrent' rendering with multiple context is impossible. That is, the first case is barely different to the second case.

So I concluded it's not thread safe. Sorry for my silliness.