Ali
Ali

Reputation: 11600

rendering scene using multithreading in opengles

I am developing a iphone game I am using multi threading for drawing multiple objects on screen ,But I am not clear that how can render a specific scene using all these threads ,should I use same FOB in all threads to update the scene or is there any other technique for rendering the scene using multiple threads .please help Code given below(Placed in separate thread) gives the bad acces

-(void)drawBricks1{

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

[EAGLContext setCurrentContext:context];

glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);

//glViewport(0, 0,backingWidth, backingHeight);
Image *ii=[[Image alloc]initWithImage:[UIImage imageNamed:@"s_2.png"]];  
[ii renderAtPoint:CGPointMake(100, 100) centerOfImage:YES];
// Clear screen
//glClear(GL_COLOR_BUFFER_BIT);

glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);


[context presentRenderbuffer:GL_RENDERBUFFER_OES];
[pool release];

}// end of the drawb

Upvotes: 0

Views: 528

Answers (1)

datenwolf
datenwolf

Reputation: 162327

The framebuffer is a multually exlusive resource. If you'd split the framebuffer into distinct areas parallel access was possible. However in the usual case of rendering with OpenGL you access a windows framebuffer as a whole. Thus each thread must lock access to the framebuffer -- this is done by the driver. This locking causes huge overhead, causing a severe performance hit. Or in a few words: OpenGL and multithreading don't mix (well).

Any why do you care anyway? The GPU will parallelize the rendering process internally, so there's absolutely no need for multithreaded access. Especially on a device like the iPhone/iPad which GPU is not designed for multithreaded access (even if it was to distinct framebuffers).

Upvotes: 1

Related Questions