应用程序在glDrawArrays上的GPUImageVideoCamera崩溃

时间:2014-11-14 04:17:35

标签: ios gpuimage

我为我们的某个应用程序集成了GPUImage。我发现经常在一个点上崩溃。 我的源代码在这里描述。

glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D, chrominanceTexture);
glUniform1i(yuvConversionChrominanceTextureUniform, 5);

glUniformMatrix3fv(yuvConversionMatrixUniform, 1, GL_FALSE, _preferredConversion);

glVertexAttribPointer(yuvConversionPositionAttribute, 2, GL_FLOAT, 0, 0, squareVertices);
glVertexAttribPointer(yuvConversionTextureCoordinateAttribute, 2, GL_FLOAT, 0, 0,                [GPUImageFilter textureCoordinatesForRotation:internalRotation]);
glDisableVertexAttribArray(GL_TRIANGLE_STRIP);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

调试时我们发现崩溃发生在glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)这一行。

任何人都可以帮我解决这次事故。

// Inrterface中的声明

GPUImageVideoCamera * videoCamera; GPUImageOutput * filter; @property(弱,非原子)IBOutlet GPUImageView * cameraView;

//实现 //在实时视频中混合图像

filter = [[GPUImageNormalBlendFilter alloc] init];
[videoCamera addTarget:filter];
[filter addTarget:cameraView];

    GPUImagePicture *overlayImage = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:[arrayOfFrames objectAtIndex:index]] smoothlyScaleOutput:YES];
    [overlayImage processImage];
    [overlayImage addTarget:filter];

我们正在使用给定的序列应用过滤器。 GPUImageVideoCamera - > GPUImageNormalBlendFilter - > GPUImageView

(void)convertYUVToRGBOutput;
{
@autoreleasepool {
@try {
[GPUImageContext setActiveShaderProgram:yuvConversionProgram];

    int rotatedImageBufferWidth = imageBufferWidth, rotatedImageBufferHeight = imageBufferHeight;

    if (GPUImageRotationSwapsWidthAndHeight(internalRotation))
    {
        rotatedImageBufferWidth = imageBufferHeight;
        rotatedImageBufferHeight = imageBufferWidth;
    }

    outputFramebuffer = [[GPUImageContext sharedFramebufferCache] fetchFramebufferForSize:CGSizeMake(rotatedImageBufferWidth, rotatedImageBufferHeight) textureOptions:self.outputTextureOptions onlyTexture:NO];
    [outputFramebuffer activateFramebuffer];

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    static const GLfloat squareVertices[] = {
        -1.0f, -1.0f,
        1.0f, -1.0f,
        -1.0f,  1.0f,
        1.0f,  1.0f,
    };

    glActiveTexture(GL_TEXTURE4);
    glBindTexture(GL_TEXTURE_2D, luminanceTexture);
    glUniform1i(yuvConversionLuminanceTextureUniform, 4);

    glActiveTexture(GL_TEXTURE5);
    glBindTexture(GL_TEXTURE_2D, chrominanceTexture);
    glUniform1i(yuvConversionChrominanceTextureUniform, 5);

    glUniformMatrix3fv(yuvConversionMatrixUniform, 1, GL_FALSE, _preferredConversion);

    glVertexAttribPointer(yuvConversionPositionAttribute, 2, GL_FLOAT, 0, 0, squareVertices);
    glVertexAttribPointer(yuvConversionTextureCoordinateAttribute, 2, GL_FLOAT, 0, 0, [GPUImageFilter textureCoordinatesForRotation:internalRotation]);
    glDisableVertexAttribArray(GL_TRIANGLE_STRIP);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);  <—-  Causes Crash Over here

}
@catch (NSException *exception) {
    NSLog(@"Exception:%@",exception.description);
}

0 个答案:

没有答案