-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
emscripten_webgl_create_context ignores EmscriptenWebGLContextAttributes.majorVersion #23372
Comments
This seems like the expsect beahvour, bit maybe there is some misunderstanding about what When no flag at all is used With The only why the version can be controlled is if support for both webgl1 and webgl2 is included in the build, and the only way to go that is to have Perhaps one thing we should be doing here is to abort/assert if |
Thank you for explaining the internal of how things work. But when you say "there is some misunderstanding", I think you have to take a step back and put yourself in the shoes of a user not knowing how the internals of Emscripten work. As far as I can tell, emscripten_webgl_create_context is a public API. When you look at the "documentation" of the API without looking at the big picture, there is no indication whatsoever that essentially the major version provided via the attribute is simply ignored unless you provide the To give you another point of view/example, just imagine for a second that the
Wouldn't you think this is quite an awkward public API? At best it is confusing. At worst it is really counter-intuitive and prone to bugs. That's how So yes I suggest, unless you want to change the way the API works, then at the bare minimum the documentation should be changed to clearly highlight the fact that the major version is ignored unless |
This is a follow up to the [ticket](#23372) discussion. When users are using my port, the window hint `GLFW_CONTEXT_VERSION_MAJOR` is ignored due to how Emscripten behaves internally. If the port sets the linker flag `MAX_WEBGL_VERSION=2`, then for a user of the library, which interact throught the GLFW API, it transparently works without asking the user to understand the internals of Emscripten and modify their build script.
I agree, updating the doc and improving emscripten_webgl_create_context both sounds like good ideas. Passing |
Do you want me to submit a PR for this work? |
Thanks would be great, thank you! |
I created the following test file:
Depending on which compilation flag it is called with,
emscripten_webgl_create_context
simply ignores the providedEmscriptenWebGLContextAttributes.majorVersion
Case 1: NO flag (ignored => 1.0 always)
Case 2:
-sMIN_WEBGL_VERSION=2
(ignored => 2.0 always)Case 3:
-sMAX_WEBGL_VERSION=2
(uses value)What this test demonstrates is that
emscripten_webgl_create_context
ignores the majorVersion flag in 2 cases.Internally,
emscripten_webgl_create_context
delegates the logic toGL.createContext
I know and understand that
GL.createContext
is being called by other parts of the code (like for example bylibrary_glfw.js
) but without attributes and so it makes sense that because there is no way to communicate a version, then you need to use a compilation flag to communicate the intent.But when
emscripten_webgl_create_context
is being called with an attribute and a defined version, I think it doesn't make any sense to ignore it.Proposed solution
What I am suggesting is to modify the code in
GL.createContext
to do something like this (pseudo code):I can work on it if you think that is something you would be open to.
The text was updated successfully, but these errors were encountered: