Rajveer
Rajveer

Reputation: 857

EAGLContext presentRenderbuffer on second thread?

I'm porting my game engine to iOS and am running in to an exception at my [EAGLContext presentRenderbuffer:] call. My engine has all rendering code on a separate thread to the main one; the engine works by creating the CAEAGLLayer and EAGLContext on the main thread, activating the context and creating the framebuffer for the view, then deactivating the context. After that for each frame my render thread then activates the context, binds the framebuffer, draws, and finally presents the render buffer.

Is it possible to call presentRenderbuffer: on a secondary thread, or is that the cause of my issues?

Upvotes: 2

Views: 1238

Answers (2)

Rajveer
Rajveer

Reputation: 857

It looks like this behaviour must have changed as I am able to use an EAGLContext on a secondary thread without issues (testing on iOS7/iOS8)

Upvotes: 2

Matic Oblak
Matic Oblak

Reputation: 16774

Unless some differences have been made the answer is NO, you may not present the render buffer on any but the main thread. The closest you can probably get to is using a texture bound FBO on the secondary thread to which you do all the drawing and then pass the texture to the main thread (needs a shared context) and redraw the texture only to the main thread render buffer.

Another way might be using a triple buffering where your draw thread would swap buffer 1 and 2 once finished drawing and the main thread would swap buffer 3 and 2 once done presenting. Let me know if you try to implement this as I am curious of the outcome.

Upvotes: 0

Related Questions