简体   繁体   English

为特定的NSThread创建GCD队列

[英]Creating a GCD queue for a specific NSThread

I would like to create a thread for offline rendering with its own OpenGL context. 我想使用自己的OpenGL上下文创建用于脱机渲染的线程。

For submitting rendering tasks, I would like to use GCD, due to its API simplicity. 由于API的简单性,我想使用GCD提交渲染任务。

Is it possible to create a GCD queue that is attached to a specific NSThread (which has its own OpenGL context)? 是否可以创建附加到特定NSThread(具有自己的OpenGL上下文)的GCD队列?

It seems to be possible, since the main queue always runs it tasks on the main thread, but I could not find anything with similar behavior for custom threads. 因为主队列总是在主线程上运行任务,所以这似乎是有可能的,但是对于自定义线程,我找不到任何具有类似行为的东西。

You can set the current context at the beginning of every task, as described here: "OpenGL Restricts Each Context to a Single Thread" . 您可以在每个任务的开始处设置当前上下文,如此处所述: “ OpenGL将每个上下文限制为一个线程”

You can also set a context for the dispatch queue, as explained here . 您还可以设置调度队列中的背景下,作为解释在这里

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

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