Function mpv_render_context_create

Source
pub unsafe extern "C" fn mpv_render_context_create(
    res: *mut *mut mpv_render_context,
    mpv: *mut mpv_handle,
    params: *mut mpv_render_param,
) -> c_int
Expand description

Initialize the renderer state. Depending on the backend used, this will access the underlying GPU API and initialize its own objects.

You must free the context with mpv_render_context_free(). Not doing so before the mpv core is destroyed may result in memory leaks or crashes.

Currently, only at most 1 context can exists per mpv core (it represents the main video output).

You should pass the following parameters:

  • MPV_RENDER_PARAM_API_TYPE to select the underlying backend/GPU API.
  • Backend-specific init parameter, like MPV_RENDER_PARAM_OPENGL_INIT_PARAMS.
  • Setting MPV_RENDER_PARAM_ADVANCED_CONTROL and following its rules is strongly recommended.
  • If you want to use hwdec, possibly hwdec interop resources.

@param res set to the context (on success) or NULL (on failure). The value is never read and always overwritten. @param mpv handle used to get the core (the mpv_render_context won’t depend on this specific handle, only the core referenced by it) @param params an array of parameters, terminated by type==0. It’s left unspecified what happens with unknown parameters. At least MPV_RENDER_PARAM_API_TYPE is required, and most backends will require another backend-specific parameter. @return error code, including but not limited to: MPV_ERROR_UNSUPPORTED: the OpenGL version is not supported (or required extensions are missing) MPV_ERROR_NOT_IMPLEMENTED: an unknown API type was provided, or support for the requested API was not built in the used libmpv binary. MPV_ERROR_INVALID_PARAMETER: at least one of the provided parameters was not valid.