GPUImage giving multiple GL_INVALID_ errors as soon as any GPUImage class is used

425 Views Asked by At

I'm trying to integrate GPUImage in a cocos2d-swift (SpriteBuilder) project so that I can use the video filters within my app. I got GPUImage working fine in the samples so I moved on and added the framework and followed the README to get GPUImage into my exported SpriteBuilder project which loads the MainScene. However as soon as I try to use anything from GPUImage I get a bunch of OpenGL errors and the app crashes.

OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at -[CCGraphicsBufferGLUnsynchronized commit] 179
OpenGL error GL_INVALID_OPERATION detected at -[CCGraphicsBufferGLUnsynchronized commit] 179
OpenGL error GL_INVALID_OPERATION detected at CCRenderStateGLTransition 285
OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at CCRenderStateGLTransition 285
OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at CCRenderStateGLTransition 285
OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at -[CCGraphicsBufferGLUnsynchronized prepare] 170
OpenGL error GL_INVALID_VALUE detected at -[CCGraphicsBufferGLUnsynchronized prepare] 170
OpenGL error GL_INVALID_VALUE detected at -[CCGLView presentFrame] 463
OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at -[CCGraphicsBufferGLUnsynchronized commit] 179
OpenGL error GL_INVALID_OPERATION detected at -[CCGraphicsBufferGLUnsynchronized commit] 179
OpenGL error GL_INVALID_OPERATION detected at CCRenderStateGLTransition 285
OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at CCRenderStateGLTransition 285
OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at CCRenderStateGLTransition 285
OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at -[CCGraphicsBufferGLUnsynchronized prepare] 170
OpenGL error GL_INVALID_VALUE detected at -[CCGraphicsBufferGLUnsynchronized prepare] 170
OpenGL error GL_INVALID_VALUE detected at -[CCGLView presentFrame] 463

I've commented out everything and tried uncommenting line by line to see what causes the crash and it happens whenever any of the GPUImage classes are instantiated. In this case, simply creating a GPUImageMovie object causes the crash:

let movieFile = GPUImageMovie(playerItem: playerItem)

Creating the GPUImageGrayscaleFilter or GPUImageView cause it as well. All I need to be able to do in my app is display a video or the camera and apply a filter to it, pretty simple on it's own; but as soon as cocos2d-swft was introduced a lot of problems showed up.

I see some people mentioning things about share groups and gl contexts and that GPUImage and cocos2d are conflicting with each other, but I've yet to find someone explaining how to actually get it working.

The entire MainScene.swift file is following (there is a button in the scene that calls the playVideo function, that's it).

import Foundation
import GPUImage

class MainScene: CCNode {
    func playVideo() {
        let mediaURL : NSURL! = NSBundle.mainBundle().URLForResource("BigBuckBunny_640x360", withExtension: "m4v")
        let mainPlayer : AVPlayer! = AVPlayer()
        let playerItem : AVPlayerItem! = AVPlayerItem(URL: mediaURL)

        let movieFile = GPUImageMovie(playerItem: playerItem)
        movieFile.runBenchmark = false
        movieFile.playAtActualSpeed = true
        let filter = GPUImageGrayscaleFilter()
        movieFile.addTarget(filter)

        let mainView = CCDirector.sharedDirector().view;

        let filterView : GPUImageView! = GPUImageView(frame: CGRectMake(0, 0, 640, 360))
        mainView.addSubview(filterView)
        filter.addTarget(filterView)

        movieFile.startProcessing()
        mainPlayer.play()
    }
}
0

There are 0 best solutions below