0

我像这样初始化我的 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 窗口的屏幕截图:石英成分

我在互联网上找不到太多关于此的内容。我希望这里有人知道可能会有所帮助的东西。

顺便说一句,我知道我可以像初始化 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)
]
4

0 回答 0