Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call OpenGL functions from another thread

My application has two threads: A and B. The A is the main thread and B is my video thread. The video thread has an initialized OpenGL context where OpenGL functions work properly. However, when I call OpenGL functions from thread A, the function failed with a 1282 error (GL_INVALID_OPERATION) Is it possible to call OpenGL functions from my main thread (A) ?

like image 686
Franck Freiburger Avatar asked Dec 08 '22 04:12

Franck Freiburger


1 Answers

  1. Unless you are doing actual background rendering of slow content, this is probably not going to give you a performance delta.

  2. On Windows, open gl contexts are per thread. Ensure that you call wglMakeCurrent from your worker thread before attempting to call open gl functions.

  3. Open GL is not thread safe. If you attempt to make the same context current on multiple threads, it won't stop you. It will just explode.

like image 95
Chris Becke Avatar answered Jan 02 '23 11:01

Chris Becke