简体   繁体   English

是否可以在非主线程中创建openGL VBO /显示列表

[英]Is it possible to create a openGL VBO/Display List in a non-main thread

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. 但是创建显示列表是不可能的,因为除了主线程之外,任何线程中都没有“ GLContext”。 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. 我已经在VBO上尝试过,但是与显示列表相比非常慢。

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. 可能更简单的方法是使用第二个线程在内存中生成VBO数据,然后使用异步数据从主线程传输到GPU(使用现在普遍使用的GL_ARB_pixel_buffer_object )。

Rendering data from a VBO should be fairly fast nowadays. 如今,从VBO渲染数据应该相当快。 Do make use of glDrawElements , glMultiDrawElements , glPrimitiveRestartIndex and the rest of the family in order to minimize the number of draw calls. 请尽量使用glDrawElementsglMultiDrawElementsglPrimitiveRestartIndex和该系列的其余部分,以尽量减少绘制调用的次数。 Display lists then should not be needed at all. 这样就根本不需要显示列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM