Polytonic / Glitter

Dead Simple OpenGL
http://polytonic.github.io/Glitter/
2.48k stars 418 forks source link

WebAssembly Port #35

Closed opiepj closed 7 years ago

opiepj commented 7 years ago

Could this be ported using Emscripten? Would be interested to see something like https://github.com/HarryLovesCode/WebAssembly-WebGL-2 be done, but not sure if all the libraries would be supported.

Polytonic commented 7 years ago

I (personally) don't have any plans to add (or otherwise port) this to emscripten in the near future, if that's what you were asking. On casual inspection, it doesn't look too difficult for you to do though. 😃

Theoretically the process should be pretty straightforward, at least, if I understand the emscripten developer's guide correctly. Assuming you've built emcc you could set CXX=emcc and feed WASM=1 as a linker flag. If you need specific instructions on how to do that, let me know. I can't provide any advice on how to build emscripten though, having never used it myself.

opiepj commented 7 years ago

I'm trying to port your demo over now, having trouble with importing assimp at the moment. But will keep you up to date.

opiepj commented 7 years ago

Hey @Polytonic I've created a repo where I'm playing around with Emscripten and WebAssembly here

I've created a simple Makefile for my build/clean tasks

Do you think you can help me convert my project to CMake? How would I insert these linker flags?

Polytonic commented 7 years ago

I am happy to provide assistance with any issues you may have using Glitter. Regrettably, I am unable to assist you with converting your project to CMake.

As I indicated previously, using emscripten should be relatively straightforward using Glitter (as I understand it). To reiterate: you should be able to do something along the lines of setting CXX=emcc at the top of CMakeLists.txt and adding something along the lines of set(CMAKE_EXE_LINKER_FLAGS "WASM=1") at the bottom. The exact syntax might vary, but hopefully that should be enough to get you started.

opiepj commented 7 years ago

Thank you @Polytonic this helps a ton!