cocoa-cb: fix invalid framebuffer operation error

in certain circumstances the returned fbo for drawing is 0, but that
fbo is solely used internally by the CAOpenGLLayer for its drawing and
should never be used. in that case we fallback to 1 or the last used fbo
instead if it was not 0.

Fixes #5546
This commit is contained in:
Akemi 2018-02-18 22:10:34 +01:00 committed by Kevin Mitchell
parent 5cc796dacc
commit 7f714c6984
1 changed files with 5 additions and 1 deletions

View File

@ -26,6 +26,7 @@ class MPVHelper: NSObject {
var mpvLog: OpaquePointer?
var inputContext: OpaquePointer?
var mpctx: UnsafeMutablePointer<MPContext>?
var fbo: GLint = 1
init(_ mpv: OpaquePointer) {
super.init()
@ -101,8 +102,11 @@ class MPVHelper: NSObject {
if mpvGLCBContext != nil {
var i: GLint = 0
glGetIntegerv(GLenum(GL_DRAW_FRAMEBUFFER_BINDING), &i)
// CAOpenGLLayer has ownership of FBO zero yet can return it to us,
// so only utilize a newly received FBO ID if it is nonzero.
fbo = i != 0 ? i : fbo
mpv_opengl_cb_draw(mpvGLCBContext, i, Int32(surface.width), Int32(-surface.height))
mpv_opengl_cb_draw(mpvGLCBContext, fbo, Int32(surface.width), Int32(-surface.height))
} else {
glClearColor(0, 0, 0, 1)
glClear(GLbitfield(GL_COLOR_BUFFER_BIT))