-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
OpenGL3 Backend: VAO is disabled for emscripten/wasm build #4266
Comments
Hello,
Can you clarify that? How does NOT using those functions create a problem? |
I created a test app for clarifying rendering bugs with other graphics lib, specifically, skia lib. The test app is created using the following code snippets
In each frame, With VAO disabled, OpenGL ES2
(Note SDL is requesting OpenGL ES2 but received ES3 context, however, imgui is built with
With VAO disabled, WebGL 1
Problems:
With VAO enabled, OpenGL ES2
(Note SDL is requesting OpenGL ES2 but received ES3 context, and imgui is built without With VAO enabled, WebGL 1
Everything is fine. ConclusionThis problem only appears in OpenGL ES2 and WebGL 1, since other opengl versions supports VAO natively, including WebGL 2. Using OES_vertex_array_object helps solve those problems for OpenGL ES2 and WebGL 1. And this test app only shows part of rendering bugs. In real application, the rendering is more severe, for example, flickering, mysterious triangles and etc. |
And please note my patches only enable VAO for WebGL 1, not for ES2 yet. |
What happens if instead of the patch you call |
Thanks for the all the details above. // Vertex arrays are not supported on ES2/WebGL1 unless Emscripten which uses an extension
#ifndef IMGUI_IMPL_OPENGL_ES2
#define IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
#elif defined(__EMSCRIPTEN__)
#define IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
#define glBindVertexArray glBindVertexArrayOES
#define glGenVertexArrays glGenVertexArraysOES
#define glDeleteVertexArrays glDeleteVertexArraysOES
#define
#endif
This way the code will be simplier. Thank you! |
Tried, but to no avail. |
PR updated. Maybe you are missing redefining
This is not possible without redefining
|
Merged! Thank you very much for the careful work and followup! |
Version/Branch of Dear ImGui:
My Issue/Question:
In OpenGL3 backend, VAO is disabled for ES2, using macros like this:
imgui/backends/imgui_impl_opengl3.cpp
Lines 304 to 306 in ad5d1a8
VAO is not available in OpenGL ES2 standard, so this is correct.
For emscripten/wasm build, ImGui assume WebGL 1 (which derived from ES2), rather than WebGL 2 (which derived from ES3) , so disabling VAO for WebGL 1 seems also correct.
However, there is
OES_vertex_array_object
extension for OpenGL ES2 and WebGL 1, which is widely and well supported in most browsers (https://caniuse.com/mdn-api_oes_vertex_array_object).Lacking VAO support in ImGui wasm build (WebGL 1) is not a good thing. It will conflicts with other graphics libraries badly, causing weird rendering bugs.
This problem bothers me for several days until VAO is fixed. Hope others may find this helpful.
Screenshots/Video:
Standalone, minimal, complete and verifiable example:
Sorry but no screenshots nor code example could be provided due to license issue. I think the problem is already clearly stated above. And patches will be provided later.
The text was updated successfully, but these errors were encountered: