简体   繁体   English

在后台加载OpenGl视图。 苹果手机

[英]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.

相关问题 iPhone 在后台收集 CoreMotion 数据。 (超过10分钟) - iPhone collecting CoreMotion data in the background. (longer than 10 mins) iPhone-线程没有停止,为什么它在我的程序后台运行。 - iphone - Thread is not stopped, why it run on my program background.? iPhone相机视图上的opengl 3d对象的背景问题 - Background problem of opengl 3d object over iphone camera view 如何在opengl-es(iphone)中将黑色背景更改为透明视图? - how to change black background to transparent view in opengl-es(iphone)? OpenGL +相机视图(iPhone) - OpenGL + Camera View (iPhone) iPhone OpenGL:添加背景图片 - iPhone OpenGL : Adding a background image 从后台返回后,我的iPhone应用程序崩溃了。 原因:UIImage问题 - My iPhone app crashes after returning from background. Cause: UIImage problem 从后台返回后,我的iPhone应用程序崩溃了。 原因:UIImage问题 - My iPhone app crashes after returning from background. Cause: UIImage problem 在表格视图iPhone的首次加载时更改选定行的背景颜色 - Changing background color for selected row on first load of table view iphone 当应用程序进入 iPhone sdk 后台时加载根视图 - Load the root view when app enter into background in iPhone sdk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM