我有一个希望将其转换为 UIImage 的 EAGLView。我可以使用此处发布的解决方案来做到这一点:
但是,如果在创建 EAGLView 和 UIImage 之间经过了一小段时间,我只能完成此操作。
这段代码创建了一个 EAGLView,然后是一个 UIImageView,它不起作用:
EAGLView *EAGLphoto = [[EAGLView alloc] initWithImage:photo.workAreaImage];
[theWorkArea.photoArea1 addSubview:EAGLphoto];
//I put a glfinish() here but it didn't help
UIImageView *photoView = [[UIImageView alloc] initWithImage:[self glToUIImage]];
//glToUIImage is taken from the link above
[theWorkArea.photoArea2 addSubview:photoView];
我假设 UIImageView 尝试在 EAGLView 完成创建之前创建。我试图在两者之间放置一个 glfinish() 但它什么也没做。当我运行代码时,EAGLView 显示正常,但 UIImageView 显示为黑色。
但是,上述代码的修改版本有效:
EAGLView *EAGLphoto = [[EAGLView alloc] initWithImage:photo.workAreaImage];
[theWorkArea.photoArea1 addSubview:EAGLphoto];
[self performSelector:@selector(getUIImage) withObject:nil afterDelay:0.1];
- (void)getUIImage {
UIImageView *photoView = [[UIImageView alloc] initWithImage:[self glToUIImage]];
//glToUIImage is taken from the link above
[theWorkArea.photoArea2 addSubview:photoView];
}
我是否错误地使用了 glfinish() ?有比我的 hack 更好的方法吗?