HarryLovesCode / WebAssembly-WebGL-2

A simple port of the "Getting started with GLFW3" code to valid code for Emscripten compilation
http://harrylovescode.github.io/WebAssembly-WebGL-2/
MIT License
67 stars 12 forks source link

How does it know how to translate glfw calls to canvas? #4

Open trusktr opened 7 years ago

trusktr commented 7 years ago

There's not a lot of code in here. How does the emscripten compile process know how to translate glfw window-creating calls to some sort of canvas output? In other words, how does emscripten know to translate cross-platform window-making calls into some sort of rectangles within the application? Seems like pure magic. Or does Emscripten have to explicitly support glfw before glfw cpuld be used, so that it can map calls to some DOM calls?

And the GL calls? Does it only work with gles, and emscripten knows how to translate to WebGL calls?

trusktr commented 7 years ago

It might help to know: what can I do, and what can't I do?

floe commented 6 years ago

I've been wondering something similar myself; if you search for *glfw* in the Emscripten installation, you find quite a bunch of related files, such as library_glfw.js. AFAICT most of the "magic" happens in there.

trusktr commented 6 years ago

Does that mean that we have to use glfw if we want to compile GL-capable programs to the web using Emscripten?

For example, what if there's some C++ game engine written using something other than glfw? Will it involve having to refactor it to use glfw?

floe commented 6 years ago

AFAICT yes, only GLFW for now. Support for other GL frameworks would require writing a new emscripten wrapper first.