Are there any examples of how to integrate SDL and WebView2? And is there any difference between using SDL2 and SDL3 for this purpose?
I want to embed a webpage inside of a SDL-based desktop application, to create a browser with features similar to the Refresh concept trailer. So all the widgets would be rendered with SDL, and input events would need to be forwarded either to the browser’s widgets or the webpage based on the mouse position.
Since I’ll most likely be starting with direct bindings to Microsoft Edge WebView2, I’m not concerned with cross-platform functionality yet. But would be happy to switch to something other than WebView2 if there are better alternatives.
I’ve managed to render a web page inside of a SDL managed window by using SDL_GetWindowWMInfo to get the native windows handle, then pass that in to CreateCoreWebView2Controller when creating the WebView. And it works as expected, where the webpage receives input events when its in focus, and SDL receives them otherwise.
There is a problem though in that the WebView is always drawn on top of anything I draw with SDL, so I can’t seem to overlay any widgets on top of it. This seems to be a longstanding issue with WebView though, and not SDL.
Has anyone found a solution or workaround for this?
Okay, I’ve concluded that WebView isn’t going to work and am going to use CEF instead. It solves the layered rendering issue and more, and in general seems like a much better fit for this kind of project.