首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >一个EAGLContext导致另一个EAGLContext不能与iOS OpenGL一起工作。

一个EAGLContext导致另一个EAGLContext不能与iOS OpenGL一起工作。
EN

Stack Overflow用户
提问于 2017-10-19 17:28:03
回答 1查看 333关注 0票数 0

我有两个类显示不同的CIImage。它们都有相同的方法来创建OpenGL对象,如下例所示。

代码语言:javascript
复制
_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对象创建如下代码所示。

代码语言:javascript
复制
_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.

代码语言:javascript
复制
    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.

代码语言:javascript
复制
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将显示两个不同的视频。如果一个是先创建的,然后另一个是创建后,后一个将显示正常,第一个将被卡住。我不知道怎么修,有人能帮我吗?非常感谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-20 18:25:56

经过调查和测试,两个GLKViews可以用下面的代码逐一显示视频。

代码语言:javascript
复制
 _context = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES3];
    [EAGLContext setCurrentContext:_context];

如果没有代码EAGLContext setCurrentContext:_context,一个GLKView将阻止另一个GLKView显示

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46835617

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档