gstreamer_gl (rust) on Windows

Steven Fontaine sir.fon1103 at
Mon Jan 31 22:05:16 UTC 2022

I'll be honest, thus far I've simply copied over examples/src/
have been hacking away at it, in an attempt to understand the logic and
understand the gstreamer_gl/glutin workflow, so I have nothing that would
really make sense even as a draft MR. But there's a couple main points of
glupload that are throwing me off.

So, as a brief summary, I'm trying to replicate examples/src/
which simply creates a glupload::App(None) (L11
and runs glupload::main_loop in that App (L12
So my troubles come from trying to make examples/src/
Windows (WGL).

With that said, my troubles start in glupload::App::new
specifically at L350
Here glupload fails by design if the platform is not linux. This is easy to
fix, but within this if statement, glupload matches the raw gl context
handle, provided by glutin, checking only for EGL and GLX, then creates a
 using gstreamer_gl_egl::GLDisplayEGL::
, gstreamer_gl_wayland::GLDisplayWayland::
or gstreamer_gl_x11::GLDisplayX11::
depending on context. Lastly, it creates a wrapped GLContext (L408
), using the GLDisplay created in the previous step. As far as I can tell,
this process handles linking the gl context provided by glutin to a
GLContext and linking that with the GLDisplay created in the
egl/wayland/x11 functions. It's this linking that I can't seem to replicate
on Windows. Since there's no equivalent functions for WGL, I'm somewhat
left in the dark here.

The most progress I've managed to make here is simply creating a new
place of the GLDisplayXXX::with_display functions, creating the wrapped
GLContext in the same way as L408

// L356
> <>

let api = App::map_gl_api(windowed_context.get_api());

 // replace L358-406
> <>
> with the following

let gl_context = if let RawHandle::Wgl(ctx) = unsafe {
> windowed_context.raw_handle() } {
>     ctx as usize
> } else {
>     panic!("Expected WGL!");
> };
// leak to ensure the display doesn't get dropped

let gl_display: &'static gstreamer_gl::GLDisplay =
> Box::leak(Box::new(gstreamer_gl::GLDisplay::new()));

let platform = gstreamer_gl::GLPlatform::WGL;

 // L408
> <>

shared_context = unsafe { gst_gl::GLContext::new_wrapped(gl_display,
> gl_context, platform, api) } .unwrap();

which compiles and makes it past App::new, but then fails in main_loop with
the following error:

failed to share contexts through wglShareLists 0xaa', src\

My intuition tells me that the GLDisplay and gl context aren't getting
properly linked, but I might be wrong. Anyway, hopefully this is helpful,
and thanks for all your help so far!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list