Skip to content

media/gstreamer: Support using GL for video for Windows

Chun-wei Fan requested to merge gst.gl.win32 into master

Hi,

This is a WIP progress to enable GL support for the GStreamer media backend on desktop Windows OpenGL or libANGLE (aka WGL), as it turns out that there are some more things that need to be done on Windows in order for things to work, namely:

  • For desktop OpenGL we need a Core GL 4.1 context for GstGL to work, so we need to first try to explicitly ask for a Core GL 4.1 context in wglCreateContextAttribARB(), if we are asking for something lower since wglCreateContextAttribARB() may just give us a GL context according to the version that we have asked for.

  • For the GstDisplay that we need for the shared GL context, it's simpler since Windows have only one GstDisplay for use for desktop OpenGL. For GLES, we can use gst_gl_display_egl_new_with_egl_display() on the EGL display that we can obtain from GDK-Win32.

  • For desktop OpenGL we need to tell libepoxy that we were calling wglMakeCurrent() outside of libepoxy (which is underlying GdkGLContext) when using GstGL, so that things won't crash due to invalid GL function pointers.

  • For desktop OpenGL we need to temporarily disable the WGL context that is made current with gdk_gl_context_make_current(), so that wglShareLists() that is called by GstGL won't fail due to ERROR_BUSY (0xAA).

Many thanks to @ystreet00 for the info, especially for the second and fourth points.

Unfortunately, this currently only works with Mesa-21.0.0 (or so), as I got the following:

<strike>gstglcolorconvert.c:2055:_create_shader:<glcolorconvert0> Failed to compile vertex shader Failed to create shader object</strike>

and I am not that good at dealing with shaders.

With blessings, thank you!

Edited by Chun-wei Fan

Merge request reports