我有两个类显示不同的CIImage。它们都有相同的方法来创建OpenGL对象,如下例所示。
_context = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES3];
_coreImageContext = [CIContext contextWithEAGLContext:_context];
_localCameraView = [[GLKView alloc]initWithFrame:self.localCameraViewPlayingRect context:_context];
_localCameraView.drawableDepthFormat = GLKViewDrawableDepthFormat24;
_localCameraView.context = _context;
glGenRenderbuffers(1, &_renderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffer);在一个glkview显示ciImage之后,我将启动另一个EAGLContext来显示不同的CIImage。另一个openGL对象创建如下代码所示。
_context = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES3];
_coreImageContext = [CIContext contextWithEAGLContext:_context];
_cameraView = [[GLKView alloc]initWithFrame:self.playingRect context:_context];
_cameraView.drawableDepthFormat = GLKViewDrawableDepthFormat24;
_cameraView.context = _context;
glGenRenderbuffers(1, &_renderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffer);我用同样的方式来显示ciimage,但它们的方法不同。1.
if(_coreImageContext && _context)
{
[_cameraConnectorLocker lock];
if(_cameraConnectorLocker && _context)
{
[_coreImageContext drawImage:ciImage inRect:CGRectMake(0, 0, self.cameraView.drawableWidth, self.cameraView.drawableHeight) fromRect:[ciImage extent]];
[_context presentRenderbuffer:GL_RENDERBUFFER];
}
[_cameraConnectorLocker unlock];
}2.
if(_coreImageContext && _context)
{
[_outputVideoLock lock];
if (_coreImageContext && _context) {
[_coreImageContext drawImage:image inRect:CGRectMake(0, 0, self.localCameraView.drawableWidth, self.localCameraView.drawableHeight) fromRect:[image extent]];
[_context presentRenderbuffer:GL_RENDERBUFFER];
}
[_outputVideoLock unlock];
}如果同时创建这两个EAGLContext对象,则两个GLKView将显示两个不同的视频。如果一个是先创建的,然后另一个是创建后,后一个将显示正常,第一个将被卡住。我不知道怎么修,有人能帮我吗?非常感谢。
发布于 2017-10-20 18:25:56
经过调查和测试,两个GLKViews可以用下面的代码逐一显示视频。
_context = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES3];
[EAGLContext setCurrentContext:_context];如果没有代码EAGLContext setCurrentContext:_context,一个GLKView将阻止另一个GLKView显示
https://stackoverflow.com/questions/46835617
复制相似问题