Skip to content

Instantly share code, notes, and snippets.

@sortofsleepy
Created March 26, 2019 18:49
Show Gist options
  • Select an option

  • Save sortofsleepy/c6f2ecc0b3f64f9a604339d0c149b9aa to your computer and use it in GitHub Desktop.

Select an option

Save sortofsleepy/c6f2ecc0b3f64f9a604339d0c149b9aa to your computer and use it in GitHub Desktop.
Sample of how to call JS from Emscripten
#include <emscripten/bind.h>
using namespace emscripten;
// note - assuming you're including your own javascript
auto window = val::global("window");
// come up with a function to create a video element.
emscripten::val videoElement = window.call<void>("MyVideoElementCreationFunction");
videoElement.set("src","url to video");
// make a texture
GLuint tex = glCreateTexture();
// texture should be populated in JS under the GL.textures array, set an ID on the element
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment