0

I am using GLFW to create my window and I am on OpenGL 4.5.

What is the most OS agnostic way (if possible) to create a second OpenGL context to share objects with the main thread for multithreading (i.e one context per thread).

0

1 Answer 1

3

I don't know whether this method is OS agnostic enough, but in my application I simply use another hidden window:

//'pWindow' is the main GL context here...
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
pGLctx[0] = glfwCreateWindow(sw, sh, "slave0", NULL, pWindow);

glfwMakeContextCurrent(pGLctx[0]); //... to make it current in calling thread...

And that works for me.

I have to say here that generally speaking rendering and multithreading (on CPU that is) can be a nightmare to handle, so it is crucial to be sure that one needs it at all.

Sign up to request clarification or add additional context in comments.

1 Comment

I would add that some (all?) OpenGL drivers have a global lock that limits interactions to 1 thread at a time which usually defeats the whole purpose of multithreading.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.