mpv-player / mpv-examples

📚
224 stars 77 forks source link

Convert Cocoa example from opengl-cb to render API #23

Closed doggy closed 5 years ago

doggy commented 6 years ago

Verified with latest mpv head sources.

clang -o cocoa-openglcb cocoa-openglcb.m -I/Users/doug/WorkSpace/mpv.git/install/include -L/Users/doug/WorkSpace/mpv.git/install/lib -lmpv -framework Cocoa -framework OpenGL
doggy commented 6 years ago

Mentioned in https://github.com/mpv-player/mpv-examples/issues/22

Akemi commented 6 years ago

i think it is also fine to rename the folder and file appropriately. instead of openglcb i would probably use rendergl.

i also can confirm it working. i will add a few remarks to the code in a bit.

on a side note, it seems like this example doesn't quit gracefully and causes a segfault or a trap, but this shouldn't hold of this PR.

doggy commented 6 years ago

Segment fault issue has been addressed: all render context's create(), free() api should be called on main thread.

doggy commented 6 years ago

Still considering the vo=opengl-cb option in this example .. I don't know what latest name it should be.

For what I saw, this option name is just an alias for libmpv, defined in latest master source code:

// For the vo option
const struct m_obj_list vo_obj_list = {
    .get_desc = get_desc,
    .description = "video outputs",
    .aliases = {
        {"gl", "gpu"},
        {"direct3d_shaders", "direct3d"},
        {"opengl", "gpu"},
        {"opengl-cb", "libmpv"},
        {0}
    },

But, also noticed something in 0.29.0 releaseNotes:

   - deprecate the OpenGL cocoa backend, option choice --gpu-context=cocoa
     when used with --gpu-api=opengl (use --vo=opengl-cb)

... shows that should be configured with gnu-* options.

It's a little bit confusing.

doggy commented 6 years ago

Oh I finally found it. https://github.com/mpv-player/mpv/blob/cb52cfae1aa7e29de08c69780a773548f708f972/DOCS/interface-changes.rst

Akemi commented 6 years ago

i still get a segfault when clicking on the red x at the top left of the window. i believe it would be better to just keep this PR to the render API changes and fix other things with another one.

if you prefer to keep everything in one PR you would need to split your latest commit [cocoa-rendergl] fix segment fault on exiting and misc improvements appropriately. the parts belonging to the render API changes should go into the first commit, one commit for fixing the deprecation warnings, one/two commit(s) for fixing the segfault(s), and another one for the misc changes. though the left over misc changes seem rather questionable to me.

doggy commented 6 years ago

@Akemi Done. A new PR should be issued for the segfault later.

Akemi commented 6 years ago

for consistency prefix the commit titles withcocoa-rendergl: instead of [cocoa-rendergl]. also the deprecation warnings for the style mask are related to macOS 10.12 rather than xcode.

doggy commented 6 years ago

Done. Appreciate everything your associates.

Akemi commented 6 years ago

LGTM and is fine to merge now.

Akemi commented 5 years ago

thx for your work and sorry it took so long. i recently got push rights back so future changes can be merged faster from now on.