-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asm.js support #16
Comments
I don't know if GLFW works with Emscripten, that would be my main concern with trying this. If it does, you're on the right track with trying to use the Emscripten toolchain, because that should set your CMAKE_MAKE_PROGRAM. I'm not sure why it's failing you. My guess is that Unix Makefile would be the proper generator to use. Someone else added the Emscripten build support to bgfx.cmake, and they provided build instructions in the travis file here: Seems they use I'm happy to help further, but I have a backlog of other things I need to get to before I can try any of this myself. Best of luck. |
Thanks for the pointers. I made some progress off of this so that it compiles: GLFW3 is supported by Emscripten. Instead of building/linking to it, you have to set add_library(glfw INTERFACE)
target_include_directories(glfw INTERFACE "${EMSCRIPTEN_ROOT_PATH}/system/include")
target_link_options(glfw INTERFACE "SHELL:-s USE_GLFW=3") # links in GLFW emscripten port There are some changes to Bigg source code required:
lastTime = ( float )glfwGetTime(); // lastTime is now a class attribute
#if BX_PLATFORM_EMSCRIPTEN
// Enter Emscripten loop
auto drawLambda = [](void* _this) { (( bigg::Application* )_this)->draw(); };
emscripten_set_main_loop_arg(drawLambda, ( void* )this, -1, 1);
#else
// Loop until the user closes the window
while ( !glfwWindowShouldClose( mWindow ) )
{
draw();
}
#endif // BX_PLATFORM_EMSCRIPTEN
So now it compiles but nothing appears on screen. I haven't figured out how to get bgfx to initiate a context inside the canvas element. There are functions for creating contexts in Emscripten from a given canvas, but I don't know how to pass that to bgfx. This suggests it's possible, but I don't know what data it expects. As for the bgfx tools: Emscripten compiles shaderc etc. into .js files. You can build them or not ( Not sure how soon I'll get to work on this again since I'm a little strapped for time as well, but I'll update this with any progress. |
A few more sidenotes for anyone else reading: The X11 and Thread errors appear because GLFW needs them. Not compiling and linking it (as outlined above) fixes all those errors. I ended up using Ninja because I didn't feel like putting make into PATH on Windows:
I didn't need emconfigure or emmake, I suppose the CMake toolchain is enough to set up all necessary variables. Also, to generate .html instead of .js for the main executable: set_target_properties(App PROPERTIES SUFFIX ".html") |
Hey,
Is compiling for asm.js supported with this particular build setup? I can compile just fine with VS2017 but I'm struggling to get it to work with CMake and the Emscripten toolchain file.
I tried different CMake generators:
I'm wondering if this is a problem with the libraries being used or a mistake on my end.
The text was updated successfully, but these errors were encountered: