關(guān)于OpenGL的前后臺問題:
Background Apps May Not Execute Commands on the Graphics Hardware
An OpenGL ES app is terminated if it attempts to execute OpenGL ES commands on the graphics hardware. iOS prevents background apps from accessing the graphics processor so that the frontmost app is always able to present a great experience to the user. Your app can be terminated not only if it makes OpenGL ES calls while in the background but also if previously submitted commands are flushed to the GPU while in the background. Your app must ensure that all previously submitted commands have finished executing before moving into the background.
If you use a GLKit view and view controller, and only submit OpenGL ES commands during your drawing method, your app automatically behaves correctly when it moves to the background. The GLKViewController class, by default, pauses its animation timer when your app becomes inactive, ensuring that your drawing method is not called.
If you do not use GLKit views or view controllers or if you submit OpenGL ES commands outside a GLKView drawing method, you must take the following steps to ensure that your app is not terminated in the background:
In your app delegate’s applicationWillResignActive: method, your app should stop its animation timer (if any), place itself into a known good state, and then call the glFinish function.
In your app delegate’s applicationDidEnterBackground: method, your app may want to delete some of its OpenGL ES objects to make memory and resources available to the foreground app. Call the glFinish function to ensure that the resources are removed immediately.
After your app exits its applicationDidEnterBackground: method, it must not make any new OpenGL ES calls. If it makes an OpenGL ES call, it is terminated by iOS.
In your app’s applicationWillEnterForeground: method, re-create any objects and restart your animation timer.
To summarize, your app needs to call the glFinish function to ensure that all previously submitted commands are drained from the command buffer and are executed by OpenGL ES. After it moves into the background, you must avoid all use of OpenGL ES until it moves back into the foreground.
iOS前后臺處理
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門托呕,熙熙樓的掌柜王于貴愁眉苦臉地迎上來含蓉,“玉大人频敛,你說我怎么就攤上這事∠诳郏” “怎么了斟赚?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長差油。 經(jīng)常有香客問我拗军,道長,這世上最難降的妖魔是什么蓄喇? 我笑而不...
- 正文 為了忘掉前任发侵,我火速辦了婚禮,結(jié)果婚禮上妆偏,老公的妹妹穿的比我還像新娘刃鳄。我一直安慰自己,他們只是感情好钱骂,可當(dāng)我...
- 文/花漫 我一把揭開白布叔锐。 她就那樣靜靜地躺著,像睡著了一般见秽。 火紅的嫁衣襯著肌膚如雪愉烙。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼稿辙!你這毒婦竟也來了昆码?” 一聲冷哼從身側(cè)響起,我...
- 正文 年R本政府宣布桅滋,位于F島的核電站慧耍,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏丐谋。R本人自食惡果不足惜蜂绎,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望笋鄙。 院中可真熱鬧师枣,春花似錦、人聲如沸萧落。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽找岖。三九已至陨倡,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間许布,已是汗流浹背兴革。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
- 剛開始欣硼,我早起純屬被逼無奈,卻在不知不覺中堅持了103天缅疟。而且分别,現(xiàn)在我也能夠合理地安排早起的這1~2個小時遍愿,做自己...