servo/surfman

How can I use surfman and webrender together?

Hankszhang opened this issue · 5 comments

Hi guys,I want to use surfman(as the GL context) and webrender (as the Render engine) to do some Rendering stuff,because surfman use ANGLE on Windows, which should achieve better robustness.
but all examples in webrender use glutin as the GL context, and Servo's implement is too complicated to understand, so I don't know how to achieve that now, I need some help~

jdm commented

Servo uses surfman and webrender - https://github.com/servo/servo/blob/master/components/webrender_surfman/lib.rs is where the glue code lives, https://github.com/servo/servo/blob/master/components/servo/lib.rs#L355-L376 is where it's initialized, and https://github.com/servo/servo/blob/master/ports/winit/headed_window.rs#L151-L162 is where it's integrated with the winit crate (along with various other uses of surfman in that file).

@jdm thanks, I got those parts. but how can I draw something(like a rect) in a surfman-winit window then, is there some code that I can refer

jdm commented

@Hankszhang You bind the surfman framebuffer and draw the rect like you usually would with webrender. The bit that integrates with winit is create_native_widget_from_winit_window, which WebrenderSurfman then uses to create a surface that's bound to a GL context.

OK, I'll try. thanks a lot~
It would be nice if there is a surfman-webrender example, look through Servo project to find out how this work is a little painful ==