void render() { obj->window()->resetOpenGLState(); QOpenGLFramebufferObject *fbo = framebufferObject(); mpv_opengl_fbo mpfbo{.fbo = static_cast<int>(fbo->handle()), .w = fbo->width(), .h = fbo->height(), .internal_format = 0}; int flip_y{0}; mpv_render_param params[] = { // Specify the default framebuffer (0) as target. This will // render onto the entire screen. If you want to show the video // in a smaller rectangle or apply fancy transformations, you'll // need to render into a separate FBO and draw it manually. {MPV_RENDER_PARAM_OPENGL_FBO, &mpfbo}, // Flip rendering (needed due to flipped GL coordinate system). {MPV_RENDER_PARAM_FLIP_Y, &flip_y}, {MPV_RENDER_PARAM_INVALID, nullptr} }; // See render_gl.h on what OpenGL environment mpv expects, and // other API details. mpv_render_context_render(obj->mpv_gl, params); obj->window()->resetOpenGLState(); } };
/*! Returns the rectangle of the surface device() that is occupied by the viewport for this surface. The origin is at the top-left. This function calls viewportGL() and then flips the rectangle upside down using the height of device() so that the origin is at the top-left instead of the bottom-left. \sa viewportGL(), device() */ QRect QGLAbstractSurface::viewportRect() const { Q_ASSERT(isValid()); QRect view = viewportGL(); int height = 0; if (surfaceType() == Window) { Q_ASSERT(window()); height = window()->height(); } else if (surfaceType() == FramebufferObject) { Q_ASSERT(framebufferObject()); height = framebufferObject()->size().height(); } return QRect(view.x(), height - (view.y() + view.height()), view.width(), view.height()); }