展示VR全景圖继找,源碼使用異步加載喘帚,實(shí)際使用時(shí)偶發(fā)崩潰,無(wú)法展示等問(wèn)題恨狈。改為同步加載后暫未發(fā)現(xiàn)崩潰問(wèn)題。
- (void)setImageWithName:(UIImage*)imageName {
? ? self.shouldUnload = NO;
? ? NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], GLKTextureLoaderOriginBottomLeft, nil];
? ? UIImage *textureImage = imageName;//[UIImage imageNamed:imageName];
? ? if(textureImage.size.height* textureImage.size.width>4096.1f*2048.1f) {
? ? ? ? return;
? ? }
? ? NSError*error;
? ? GLKTextureInfo * _Nullable textureInfo = [GLKTextureLoader textureWithCGImage:textureImage.CGImage options:options error:&error];
? ? [[PanoramaManager sharedInstance] registerView:self];? ? ? ? [[PanoramaManager sharedInstance] unRegisterView:self];
? ? ? ? GLuintname = textureInfo.name;
? ? ? ? glDeleteTextures(1, &name);
? ? ? ? glDrawElements(GL_TRIANGLES, self.numIndices, GL_UNSIGNED_SHORT, 0);
? ? /// 設(shè)置著色器的紋理
? ? self.effect = [[GLKBaseEffect alloc] init];
? ? self.effect.texture2d0.enabled = GL_TRUE;
? ? self.effect.texture2d0.name= textureInfo.name;
}