Home glFramebufferRenderbuffer failed when scale layer
Reply: 0

glFramebufferRenderbuffer failed when scale layer

user2336
1#
user2336 Published in July 17, 2018, 12:03 am

In my app, I will play YUV420 data in a view and support scale video through gesture。I implent this by puting two views in a UISCrollview,let's call them _playerView and _shadowView, _playerView is the view playing video and _shadowView scaled throhg scrollview。 when the scale factor is under about 3(not a exact number), it works fine.But when I scale to bigger, the video is not playing any more.I don't understand why? some code as follows:

update size:

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
{
    //不允许缩小
    if (_scrollView.zoomScale < 1.0) {
        _scrollView.zoomScale = 1.0;
    }   
    _playerView.frame = _shadowView.frame;
}

and then will attatch _playerView.layer in layoutSubviews method。

- (void)layoutSubviews
{
    [super layoutSubviews];
    UIView *shadowView = [self.superview viewWithTag:SHADOW_VIEW_TAG];
    if (shadowView) {
        self.frame = shadowView.frame;
    }

    [[EAGLContext sharedLock] lock];
    [EAGLContext setCurrentContext:_glContext];
    [self destoryFrameAndRenderBuffer];
    [self createFrameAndRenderBufferWithWidth:self.frame.size.width height:self.frame.size.height];
    [[EAGLContext sharedLock] unlock];
}

- (void)destoryFrameAndRenderBuffer
{
    if (_framebuffer) {
        glDeleteFramebuffers(1, &_framebuffer);
    }
    if (_renderBuffer) {
        glDeleteRenderbuffers(1, &_renderBuffer);
    }
    _framebuffer = 0;
    _renderBuffer = 0;
}

- (BOOL)createFrameAndRenderBuffer
{
    glGenFramebuffers(1, &_framebuffer);
    glGenRenderbuffers(1, &_renderBuffer);

    glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer);
    glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffer);

    //[UIView layer] must be used from main thread only
    if (![_glContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.layer]) {
        NSLog(@"attach failed");
    }
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _renderBuffer);
    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
        NSLog(@"create buffer failed:0x%x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
        return NO;
    }
    return YES;
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301001 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO