Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stream a webGL canvas with WebRTC?

I have an webGL canvas rendering an 3D hologram image using Three.js and I want to stream it as a video to another pc.

I already tried the code below and didn't work.

  var gl = renderer.getContext();       //get webGl context 
  var canvas = gl.canvas;               //get gl's canvas 

  var video = document.querySelector('video');
  var stream = canvas.captureStream();
  video.srcObject = stream;

Is it possible to stream and webGl canvas with WebRTC?

like image 883
Patricia Avatar asked Oct 12 '25 08:10

Patricia


1 Answers

this is not yet fully supported in Chrome (Firefox should work since 43), you need "Experimental Web Platform features" in chrome://flags. See this demo for a classical teapot example.

like image 193
Philipp Hancke Avatar answered Oct 16 '25 07:10

Philipp Hancke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!