QCRenderer.renderAtTime失败,并且帧缓冲操作无效'

时间:2014-10-30 14:40:33

标签: opengl swift quartz-composer nsopenglview

我像这样初始化我的QCRenderer:

let glPFAttributes:[NSOpenGLPixelFormatAttribute] = [
    UInt32(NSOpenGLPFABackingStore),
    UInt32(0)
]
let glPixelFormat = NSOpenGLPixelFormat(attributes: glPFAttributes)
if glPixelFormat == nil {
    println("Pixel Format is nil")
    return
}
let openGLView = NSOpenGLView(frame: glSize, pixelFormat: glPixelFormat)
let openGLContext = NSOpenGLContext(format: glPixelFormat, shareContext: nil)
let qcRenderer = QCRenderer(openGLContext: openGLContext, pixelFormat: glPixelFormat, file: compositionPath)

在代码的下面,我像这样调用renderAtTime:

if !qcRenderer.renderAtTime(frameTime, arguments: nil) {
    println("Rendering failed at \(frameTime)s.")
    return
}

总是会产生此错误消息:

2014-10-30 15:30:50.976 HQuartzRenderer[3996:692255] *** Message from <QCClear = 0x100530590 "Clear_1">:
OpenGL error 0x0506 (invalid framebuffer operation)
2014-10-30 15:30:50.976 HQuartzRenderer[3996:692255] *** Message from <QCClear = 0x100530590 "Clear_1">:
Execution failed at time 0.000
2014-10-30 15:30:50.976 HQuartzRenderer[3996:692255] *** Message from <QCPatch = 0x100547860 "(null)">:
Execution failed at time 0.000
Rendering failed at 0.0s.

Quartz Composition只是一个简单的GLSL着色器,在Quartz Composer中运行得很好。 以下是Quartz Composer窗口的屏幕截图:Quartz Composition

在互联网上我找不到多少东西。我希望这里有人知道可能有所帮助的事情。

顺便说一下,我知道我可以像

那样初始化QCRenderer
let qcRenderer = QCRenderer(offScreenWithSize: size, colorSpace: CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), composition: qcComposition)

但我希望利用GPU的多重采样功能来获得抗锯齿图像。与以4倍大小渲染相比,这需要更高效,然后手动缩小图像尺寸。

修改:将像素格式更改为

let glPFAttributes:[NSOpenGLPixelFormatAttribute] = [
    UInt32(NSOpenGLPFAAccelerated),
    UInt32(NSOpenGLPFADoubleBuffer),
    UInt32(NSOpenGLPFANoRecovery),
    UInt32(NSOpenGLPFABackingStore),
    UInt32(NSOpenGLPFAColorSize), UInt32(128),
    UInt32(NSOpenGLPFADepthSize), UInt32(24),
    UInt32(NSOpenGLPFAOpenGLProfile),
    UInt32(NSOpenGLProfileVersion3_2Core),
    UInt32(0)
]

0 个答案:

没有答案