-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Unable to create WebGL2 context using GLFW, and I can't find any example code for doing this with GLFW with Emscripten #20363
Comments
I don't have a quick answer for you but I can give you some pointers that might help. Emscipten's GLFW implementation lives in JavaScript here: https://github.com/emscripten-core/emscripten/blob/main/src/library_glfw.js. Specifically the code that create the GL context is here: emscripten/src/library_glfw.js Lines 1030 to 1040 in 668703b
It doesn't look like that code is capable to creating a context with different GL versions, so perhaps it needs updating? |
However is does look like emscripten/src/library_browser.js Lines 265 to 275 in 668703b
Can you try building with |
I'm pulling my hair out trying to get a basic "HelloTriangle" shader example working with WebGL2 and GLFW. The code works natively (OpenGL ES 3), but when I try to run the Emscripten version I get errors about "storage qualifier supported in GLSL ES 3.00 and above only" and "Floating-point suffix unsupported prior to GLSL ES 3.00" which leads me to believe I'm still getting a WebGL 1 context.
I did get a similar thing to work using the webgl_sample_query.cpp file from the Emscripten tests; the problem is that that sample doesn't use GLFW to create the context, and the GLFW boilerplate is different enough to that sample's boilerplate that I can't easily see how to merge the two. I did try copying some code over (you'll see in main.cpp), but it has no effect.
Based on all I've read it should (?) "just work" using the GLFW boilerplate, but this doesn't (apparently) result in a WebGL2 context. I thought, maybe I could just read the source code and see what needs to be passed to make GLFW hit the happy path of creating a WebGL2 enabled context, but I can't figure out where this source code file is. Because presumably when Emscripten is passed "-s USE_GLFW=3" that is using some custom version of GLFW built in to Emscripten. (That's also why I'm reporting this as a bug on the Emscripten repository and not against the GLFW project.)
The "Optimizing WebGL" page in the Emscripten docs gives a lot of different options based on different compatibility scenarios, but I'd really appreciate a succinct "here's all the compile options" and "here's all the link options" one should be using for new code for WebGL2.
Moreover if Emscripten supports GLFW, and Emscripten supports WebGL2, and GLFW supports OpenGL ES3, does Emscripten support WebGL2 using GLFW? If the answer is no, you might want to put a warning about that gotcha in the documentation. If the answer is yes, where's the example code?
Thanks.
I've attached the code I'm using (it's not very long):
CMakeLists.txt
main.cpp.txt
webgl_sample_query.cpp.txt
Output of emcc -v:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.22 (a9981ae)
clang version 16.0.0 (https://github.com/llvm/llvm-project 8491d01cc385d08b8b4f5dd097239ea0009ddc63)
The text was updated successfully, but these errors were encountered: