[英]Load an OpenGl view in the background. iPhone
I have an OpenGL view that renders a 3D model. 我有一个渲染3D模型的OpenGL视图。 It is a basic modification on Apples EAGLView.
这是对Apple EAGLView的基本修改。 This view is added to a controller's .view and displayed with presentModalViewController: .
该视图被添加到控制器的.view并与presentModalViewController:一起显示。 I would like to do all of the model loading, and OpenGL state configuration in a background thread at app launch before the user chooses to display the view.
我想在用户选择显示视图之前在应用程序启动时在后台线程中进行所有模型加载和OpenGL状态配置。 Is this possible?
这可能吗? Can I load textures, setup lighting, and generally just get everything ready to render in a background thread?
我可以加载纹理,设置照明,并且通常只准备将所有内容渲染到背景线程中吗? My fear is that the Cocoa touch portions of the app on the main are going to manipulate the OpenGL state while I am setting up my renderer in the background.
我担心的是,当我在后台设置渲染器时,主界面上应用程序的可可触摸部分将要操纵OpenGL状态。 The controller will be displayed from the main thread of course.
当然,控制器将从主线程显示。 This level of understanding of OpenGl-ES is not something I deal with often, so please be gentile if my question is strange in any way :)
对OpenGl-ES的这种了解不是我经常处理的事情,因此,如果我的问题有任何奇怪之处,请谨慎对待:)
You absolutely can do background loading on a thread. 您绝对可以在线程上进行后台加载。 Some of the key points: - There is probably not much of a win to moving OGL state setup to a background thread - the total amount of change you'd induce in a context before the start of the first draw doesn't add up to a ton of time.
一些关键点:-将OGL状态设置移动到后台线程可能不会有太大的成功-在第一次绘制开始之前,您在上下文中引起的更改总量不会累加大量的时间 Background loading is useful for textures and VBOs, as well as the load time that has to happen first to get the data to feed to the GL.
后台加载对于纹理和VBO以及将数据馈入GL首先必须发生的加载时间很有用。 - You'll need to detach the context from the main thread and move it to the worker thread.
-您需要将上下文与主线程分离,并将其移至工作线程。 We do this using pthreads to "send" the context to the worker.
我们使用pthreads将上下文“发送”给工作人员来完成。 - In our use, we hide the GL view to ensure that it doesn't need to be drawn while in a load state.
-在我们的使用中,我们隐藏了GL视图以确保在处于加载状态时无需绘制该视图。 (Frankly during load it may not contain anything useful.) So during async load the visible UI is all non-GL Cocoa.
(坦率地说,在加载过程中,它可能没有任何有用的东西。)因此,在异步加载过程中,可见的UI都是非GL Cocoa。
This approach is more difficult than what you would do on the desktop: simply share the objects in two contexts (so that you can load and draw at the same time). 这种方法比在桌面上执行时要困难得多:只需在两个上下文中共享对象(以便您可以同时加载和绘制)。 When we looked at that approach more than a year ago, it wasn't possible on IOS;
当我们一年多以前研究这种方法时,在IOS上是不可能的。 it may be possible now, I do not know.
我不知道现在有可能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.