ios - How can I draw the same GL_RENDERBUFFER content to two different CAEAGLLayer? -
in project try render content opengl, work fine in single view. want use 1 eaglcontext
simultaneously render same gl_renderbuffer content 2 views, has different frame.
i try seems - renderbufferstorage:fromdrawable:
can't bind 2 caeagllayer
.how can work? appreciate!
- (void)setupframebuffer { glgenrenderbuffers(1, &maincolorrenderbuffer); glbindrenderbuffer(gl_renderbuffer, maincolorrenderbuffer); //****************it can't work*********** [maincontext renderbufferstorage:gl_renderbuffer fromdrawable:(id<eagldrawable>)anotherglview.layer]; [maincontext renderbufferstorage:gl_renderbuffer fromdrawable:(id<eagldrawable>)self.layer]; //**************************************** glgetrenderbufferparameteriv(gl_renderbuffer, gl_renderbuffer_width, &mainbufferwidth); glgetrenderbufferparameteriv(gl_renderbuffer, gl_renderbuffer_height, &mainbufferheight); glgenframebuffers(1, &mainframebuffer); glbindframebuffer(gl_framebuffer, mainframebuffer); glframebufferrenderbuffer(gl_framebuffer, gl_color_attachment0, gl_renderbuffer, maincolorrenderbuffer); glframebufferrenderbuffer(gl_framebuffer, gl_depth_attachment, gl_renderbuffer, maindepthrenderbuffer); unsigned status = glcheckframebufferstatus(gl_framebuffer); nsassert(status == gl_framebuffer_complete, @""); glviewport(0, 0, mainbufferwidth, mainbufferheight); }
Comments
Post a Comment