Original Post
In my current setup, I mainly have two threads running: a rendering thread, and a resource loading thread. In trying to create functions to load meshes, I've hit a brick wall. My rendering thread owns the OpenGL-context, however, when loading a mesh I need a vertex buffer and index buffer in the resource loading thread. I assume these buffers can only be allocated by the thread owning the OpenGL-context. So my questions are:
- Is my assumption right that only the thread owning the OpenGL-context can allocate buffers? Or can I call glGenBuffers in the resource loading thread and use the object name in the rendering thread?
- When I have a buffer, is it the rendering thread that must call lock() and unlock() on it?
- After calling lock() and having a pointer to the buffer data, can only the rendering thread write to that memory?
- And finally, my current plan is to load the vertex data in a seperate array, then copy that to a vertex buffer on the rendering thread. It sounds inefficient to me, but is there any other (better) way?