ios - overlaySKScene not rendered when using SCNRenderer -
i'm using scnrenderer
render scene existing opengl context (basically modified version of vuforia imagetarget sample) , overlayskscene
show annotations objects in scene.
since update ios 9 overlayskscene
no longer rendered. none of per frame actions (update:
, didevaluateactions
, ...) being called.
it worked ios 8 , same skscene
still works scnview
in different view controller in same app.
context setup:
self.context = [[eaglcontext alloc] initwithapi:context.api sharegroup:scnviewcontext.sharegroup];
opengl initialitaion (mostly copied vuforia sample):
- (void)createframebuffer { if (self.context) { // create default framebuffer object glgenframebuffers(1, &_defaultframebuffer); glbindframebuffer(gl_framebuffer, self.defaultframebuffer); // create colour renderbuffer , allocate backing store glgenrenderbuffers(1, &_colorrenderbuffer); glbindrenderbuffer(gl_renderbuffer, self.colorrenderbuffer); // allocate renderbuffer's storage (shared drawable object) [self.context renderbufferstorage:gl_renderbuffer fromdrawable:(caeagllayer*)self.layer]; glint framebufferwidth; glint framebufferheight; glgetrenderbufferparameteriv(gl_renderbuffer, gl_renderbuffer_width, &framebufferwidth); glgetrenderbufferparameteriv(gl_renderbuffer, gl_renderbuffer_height, &framebufferheight); // create depth render buffer , allocate storage glgenrenderbuffers(1, &_depthrenderbuffer); glbindrenderbuffer(gl_renderbuffer, self.depthrenderbuffer); glrenderbufferstorage(gl_renderbuffer, gl_depth_component16, framebufferwidth, framebufferheight); // attach colour , depth render buffers frame buffer glframebufferrenderbuffer(gl_framebuffer, gl_color_attachment0, gl_renderbuffer, self.colorrenderbuffer); glframebufferrenderbuffer(gl_framebuffer, gl_depth_attachment, gl_renderbuffer, self.depthrenderbuffer); glframebufferrenderbuffer(gl_framebuffer, gl_stencil_attachment, gl_renderbuffer, self.stencilrenderbuffer); // leave colour render buffer bound future rendering operations act on glbindrenderbuffer(gl_renderbuffer, self.colorrenderbuffer); } } - (void)setframebuffer{ // eaglcontext must set each thread wishes use it. set // first time method called (on render thread) if (self.context != [eaglcontext currentcontext]) { [eaglcontext setcurrentcontext:self.context]; } if (!self.defaultframebuffer) { // perform on main thread ensure safe memory allocation // shared buffer. block until operation complete prevent // simultaneous access opengl context [self performselectoronmainthread:@selector(createframebuffer) withobject:self waituntildone:yes]; } glbindframebuffer(gl_framebuffer, self.defaultframebuffer); } - (bool)presentframebuffer { // setframebuffer must have been called before presentframebuffer, therefore // know context valid , has been set (render) thread // bind colour render buffer , present glbindrenderbuffer(gl_renderbuffer, self.colorrenderbuffer); return [self.context presentrenderbuffer:gl_renderbuffer]; }
scnrenderer setup:
self.skscene = [[markeroverlayscene alloc] initwithsize:cgsizemake(2048, 2048)]; self.renderer = [scnrenderer rendererwithcontext:self.context options:nil]; self.renderer.autoenablesdefaultlighting = no; self.renderer.delegate = self; self.renderer.overlayskscene = self.skscene; self.renderer.playing = yes; if (self.sceneurl) { self.renderer.scene = [scnscene scenewithurl:self.sceneurl options:nil error:nil]; [self.renderer prepareobjects:@[self.renderer.scene] withcompletionhandler:^(bool success) { }]; }
vuforia render callback:
- (void)renderframeqcar { [self setframebuffer]; // clear colour , depth buffers glclear(gl_color_buffer_bit | gl_depth_buffer_bit | gl_stencil_buffer_bit); // render video background , retrieve tracking state qcar::state state = qcar::renderer::getinstance().begin(); qcar::renderer::getinstance().drawvideobackground(); glenable(gl_depth_test); glenable(gl_cull_face); glcullface(gl_back); if(qcar::renderer::getinstance().getvideobackgroundconfig().mreflection == qcar::video_background_reflection_on) { glfrontface(gl_cw); //front camera } else { glfrontface(gl_ccw); //back camera } (int = 0; < state.getnumtrackableresults(); ++i) { // trackable const qcar::trackableresult* result = state.gettrackableresult(i); qcar::matrix44f modelviewmatrix = qcar::tool::convertpose2glmatrix(result->getpose()); scnmatrix4 matrix = [self convertarmatrix:modelviewmatrix]; matrix = scnmatrix4mult(scnmatrix4makerotation(m_pi_2, 1, 0, 0), matrix); matrix = scnmatrix4mult(scnmatrix4makescale(10, 10, 10), matrix); self.artransform = matrix; } if (state.getnumtrackableresults() == 0) { self.artransform = scnmatrix4identity; } [self.renderer renderattime:cfabsolutetimegetcurrent() - self.starttime]; gldisable(gl_depth_test); gldisable(gl_cull_face); qcar::renderer::getinstance().end(); [self presentframebuffer]; }
mess skscene. settings. when switched ios9 no touches getting through. had add skscene.userinteractionenabled = no; not needed in ios8. guess defaults have changed or setting overlay no longer changes defaults.
regardless, issue skscene settings.
Comments
Post a Comment