ios的opengl究竟能不能在非主線程渲染?
關鍵不是主線程 or 子線程,而是調用 opengl 的線程中是否調用過 setCurrentContext。EAGLContext Class Reference:
A context encapsulates all OpenGL ES state for a single thread in your app. When you call any OpenGL ES API function, OpenGL ES evaluates it with respect to the calling thread』s current context. Because OpenGL ES functions require a current context, you must use this method to select a context for the current thread before calling any OpenGL ES function. Unless otherwise specified, OpenGL ES commands calls made in the same context complete in the order they are called.
OpenGL ES retains the context when it is made current, and it releases the previous context. To prevent a non-current context from being deallocated, your app should keep a strong reference to the context (or retain it, if using manual reference counting). Calling this method with a nil parameter releases the current context and leaves OpenGL ES unbound to any drawing context.
You should avoid making the same context current on multiple threads. OpenGL ES provides no thread safety, so if you want to use the same context on multiple threads, you must employ some form of thread synchronization to prevent simultaneous access to the same context from multiple threads.
可參考另一個回答,不一樣的問題,但是問的是一模一樣的事情。
ios 沒有用 egl,你可以認為 EAGL 是與 egl、wgl、glx 並列的另一種 window system。cocos2dx 如何做到無卡頓載入紋理? - Vinjn張靜的回答ios可以 Android 各種坑。。。
推薦閱讀: