Webview OF integration - how to dispatch?

Hi,

i want to render a webview into an OF-App on Windows.
I added webview ( GitHub - webview/webview: Tiny cross-platform webview library for C/C++/Golang. Uses WebKit (Gtk/Cocoa) and Edge (Windows) ) into a OF-App, but the webview opens in another window. How can i dispatch the webview with ofGetMainLoop Callback?
I try to embedd any Website or Webapp into a oF like a widget.
Over a Callback?


static void mainLoopCB(webview_t w, void* arg) {
	ofxWebView* webview = static_cast<ofxWebView*>(arg);
	webview_dispatch(w, mainLoopCB, webview);
	ofGetMainLoop()->loopOnce();
}

// in ofApp::setup(){ wv.run();  }

void ofxWebView::run() 
{
	// pointer to webview
	webview::webview* w = new webview::webview(true, nullptr);
	webview_dispatch(static_cast<webview_t>(w), mainLoopCB, this);
	w->set_size(980, 650, WEBVIEW_HINT_NONE);
	w->set_size(980, 650, WEBVIEW_HINT_MIN);
	w->navigate("https://madhat.de");
	w->run();
}

^ofxWebView.cpp

#include "webview.h"

class ofxWebView { 
public: 
  void run(); 
};

^ofxWebView.h

Or is there a simpler way to embedd a WebView2 under Windows?

hey @pce ,
there are some add-on attempts around,
but not sure they are working well:

I remember some maybe older chromium / CEF like:

these addons are quite outdated and ultralight does not run on osx.
i was also experimenting a bit with webview. first i had the same thoughts as you, intergrating a webiew in an oF app window, but i realised that is not that easy. i was wondering if the other way round is easier, rendering all the oF graphics offscreen and then somehow displaying the texture in an html canvas. any thoughts on this?

thanks, webview seems promising, because it uses the underlying or bundled platform specific webview component.

@thomasgeissl
The other way arround “Rendering an oF App in a HTML Canvas” could be done in an Electron App, i heard someone has done that with Unity. One could spawn the App in a transparent electron window for example.

electron uses node in the background and chromium for the frontend.
there is also tauri that uses rust on the backend side and their wry rendering libraries, that i think uses the same platform-specific libs as webview.
i wanna use oF/c++ for the backend and webview or maybe even jule’s choc utilities collection.
but i am not sure if textures can be shared directly with the frontend, similar approach to syphon/spout.

ok, manually sharing base64 encoded textures and metadata as json from oF to a WebApp (frontend with SocketServer or Node-OSC) is not an option for your case? Or OF-Pixelstreaming?

webview supports two-way binding, there should not be the need for the ws approach. for performance critical applications it would be nice to share the texture directly instead of loading it from gpu, serializing it, and sending it over to the frontend.
I did some research and seems to be impossible, probably a security issue.