renderOpenGL() called in the message thread?

opengl

#1

I understand that OpenGLRenderer’s renderOpenGL() function is called in a rendering thread, which is ALWAYS different from JUCE message thread ([MODIFIED] It turned out to be WRONG. See Jules’ reply). However I noticed that it was called in the message thread during I was resizing the window.

Is this a right behaviour? Then does it mean I need to do synchronization stuff assuming that the function could be called by multiple threads simultaneously?

You may easily see this happen if you just add the lines below in MainContentComponent::render() of “OpenGLAppExample”.

  const std::thread::id tid = std::this_thread::get_id();
  std::cout << "Thread ID " << tid << std::endl;

I’m using JUCE5 on Mac OS X 10.11.6 (El Capitan)

Thanks in advance.


#2

It’ll never be called by multiple threads simultaneously, but you can’t make any other assumptions about which thread will be used.


#3

Ah it made clear.

Thank you!