Re: Multithreading
Posted by
Wade Walker on
Jan 09, 2011; 4:00pm
URL: https://forum.jogamp.org/Multithreading-tp2221001p2221750.html
Hopefully Demoscene or Julien can comment on this -- they've probably got direct experience doing it

I've always seen this suggested:
main thread:
gl.glBindBuffer()
gl.glBufferData() // use null data pointer so no data is copied
gl.glMapBuffer() // returns a ByteBuffer or similar object
secondary thread:
write data to mapped ByteBuffer
main thread:
gl.glUnmapBuffer()
Supposedly, as long as you don't try to use that bound VBO in the main thread until after you unmap it, this allows you to move the expensive data write into a second thread. You also keep all OpenGl calls on the main thread, and don't have to share the GL context between threads, which reduces the potential for multithreaded programming errors or driver bugs with context sharing.
You'll probably have to do some experiments to find the fastest way, since the performance of multithreaded programs can be counter-intuitive.