ofxImGui icon indicating copy to clipboard operation
ofxImGui copied to clipboard

Emscripten fix

Open Jonathhhan opened this issue 1 year ago • 3 comments

With adding #include "stack" to ImHelpers.h (and a few small additional changes) it works also with Emscripten.

Jonathhhan avatar Dec 02 '22 05:12 Jonathhhan

Hey, Thanks for your PR. Have you seen the develop branch ? We're planning to transition to that branch. It should support Emscripten too. I'd love to know if it works on Emscripten.

Daandelange avatar Mar 19 '23 19:03 Daandelange

@Daandelange I tried the develop branch, and it seems to be more complicated to make it work. First I had to add the GLES includes to EngineOpenFrameworks.h, but then I still get this error:

wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl3.o: undefined symbol: glPolygonMode
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl3.o: undefined symbol: glPolygonMode
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glGetTexEnviv
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glPushAttrib
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glTexCoordPointer
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glColorPointer
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glDisableClientState
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glDisableClientState
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glDisableClientState
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glPopMatrix
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glPopMatrix
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glPopAttrib
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl3.o: undefined symbol: glPolygonMode
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl3.o: undefined symbol: glPolygonMode
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glShadeModel
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glTexEnvi
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glEnableClientState
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glEnableClientState
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glEnableClientState
wasm-ld: error: /home/jonathan/Desktop/of_v20230320_linux64gcc6_release/addons/obj/emscripten/Release/ofxImGui/libs/imgui/backends/imgui_impl_opengl2.o: undefined symbol: glDisableClientState
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)

But I am sure it will work with the right changes (because it does work well with the master branch). Here you can try the demo example (compiled with my fork of the master branch and the current OF and Emscripten): https://ofximgui.handmadeproductions.de/

Jonathhhan avatar Mar 21 '23 03:03 Jonathhhan

Hi, thanks for giving it a try. :)
These errors are GLES2 symbols that I bypassed by injecting GLES1 hacks, you probably need that include too, you're probably missing a macro condition to include it. ImGui doesn't support GLES1, OF does.
Weird that imgui_impl_opengl3.cpp also throws one error, I only had them in imgui_impl_opengl2.cpp

Look in ofxImGuiConstants.h if the correct macros are defined. I'll be able to help deeper within a few weeks.

Daandelange avatar Mar 21 '23 07:03 Daandelange