Reputation: 692
I have a infinitely generating world that works pretty much fine. Every time a new chunk is generated it's height map is generated in a second thread. But creating the display list is impossible to do because there is "no GLContext" in any thread but the main one. This means that every time a new chunk is generated there is a small lag spike which when a few are generated at once becomes noticeable.
What I'm asking is whether or not there is a way to create the display list or vertex buffer object in another thread and then bind it or something in the main one?
I have already tried it with VBO's but it was very slow compared to display lists.
Upvotes: 1
Views: 231
Reputation: 11031
A possibly simpler approach would be to use the second thread to generate the VBO data in memory and then use asynchronous data transfer to the GPU (using the now ubiquitous GL_ARB_pixel_buffer_object) from the main thread.
Rendering data from a VBO should be fairly fast nowadays. Do make use of glDrawElements
, glMultiDrawElements
, glPrimitiveRestartIndex
and the rest of the family in order to minimize the number of draw calls. Display lists then should not be needed at all.
Upvotes: 1