emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.82k stars 3.31k forks source link

Emulation of older Desktop OpenGL API features #21352

Open ZYF500 opened 9 months ago

ZYF500 commented 9 months ago

Version of emscripten/emsdk: 3.1.37 Version of qt: 6.6

Failing command line in full:

10:47:03: 正在启动 "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j8

C:\Qt\6.6.1\mingw_64\bin\qmake6.exe -install sed -e s/@APPNAME@/Cpp-QtWidgetsApplication-Test/g -e s/@PRELOAD@//g C:/Qt/6.6.1/wasm_singlethread/plugins/platforms/wasm_shell.html > C:/Users/14240/桌面/ZYF.Code/build-Cpp-QtWidgetsApplication-Test-WebAssembly_Qt_6_6_1_single_threaded-Debug/Cpp-QtWidgetsApplication-Test.html
copy /y C:\Qt\6.6.1\wasm_singlethread\plugins\platforms\qtloader.js C:\Users\14240\桌面\ZYF.Code\build-Cpp-QtWidgetsApplication-Test-WebAssembly_Qt_6_6_1_single_threaded-Debug
copy /y C:\Qt\6.6.1\wasm_singlethread\plugins\platforms\qtlogo.svg C:\Users\14240\桌面\ZYF.Code\build-Cpp-QtWidgetsApplication-Test-WebAssembly_Qt_6_6_1_single_threaded-Debug
        1 file(s) copied.
        1 file(s) copied.
em++ -s 'ASYNCIFY_IMPORTS=qt_asyncify_suspend_js,qt_asyncify_resume_js' -s WASM=1 -s MAX_WEBGL_VERSION=2 -s ERROR_ON_UNDEFINED_SYMBOLS=1 --bind -s FETCH=1 -s MODULARIZE=1 -s EXPORT_NAME=createQtAppInstance -s WASM_BIGINT=1 -s STACK_SIZE=5MB -s LEGACY_GL_EMULATION=1 -g2 -s WASM=1 -s MAX_WEBGL_VERSION=2 -s ERROR_ON_UNDEFINED_SYMBOLS=1 --bind -s FETCH=1 -s MODULARIZE=1 -s EXPORT_NAME=createQtAppInstance -s WASM_BIGINT=1 -s STACK_SIZE=5MB -s DEMANGLE_SUPPORT=1 --profiling-funcs -s EXPORTED_RUNTIME_METHODS=UTF16ToString,stringToUTF16,JSEvents,specialHTMLTargets,FS -sALLOW_MEMORY_GROWTH -s INITIAL_MEMORY=50MB C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledFreetype.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledLibpng.a -o .\Cpp-QtWidgetsApplication-Test.js   @object_script.Cpp-QtWidgetsApplication-Test.js
wasm-ld: error: main.obj: undefined symbol: glVertex3d
wasm-ld: error: main.obj: undefined symbol: glVertex3d
wasm-ld: error: main.obj: undefined symbol: glVertex3d
wasm-ld: error: main.obj: undefined symbol: glVertex3d
wasm-ld: error: main.obj: undefined symbol: glVertex3d
wasm-ld: error: main.obj: undefined symbol: glVertex3d
em++: error: 'C:/emsdk-main/upstream/bin\wasm-ld.exe -o .\Cpp-QtWidgetsApplication-Test.wasm C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledFreetype.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledLibpng.a main.obj cpp-qtwidgetsapplication-test.js_plugin_import.obj C:/Qt/6.6.1/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_1/.rcc/qrc_wasmfonts.cpp.o C:/Qt/6.6.1/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_2/.rcc/qrc_wasmwindow.cpp.o C:/Qt/6.6.1/wasm_singlethread/lib/objects-Release/Gui_resources_1/.rcc/qrc_qpdf.cpp.o C:/Qt/6.6.1/wasm_singlethread/lib/objects-Release/Gui_resources_2/.rcc/qrc_gui_shaders.cpp.o C:/Qt/6.6.1/wasm_singlethread/plugins/platforms/libqwasm.a C:/Qt/6.6.1/wasm_singlethread/plugins/iconengines/libqsvgicon.a C:/Qt/6.6.1/wasm_singlethread/plugins/imageformats/libqgif.a C:/Qt/6.6.1/wasm_singlethread/plugins/imageformats/libqicns.a C:/Qt/6.6.1/wasm_singlethread/plugins/imageformats/libqico.a C:/Qt/6.6.1/wasm_singlethread/plugins/imageformats/libqjpeg.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledLibjpeg.a C:/Qt/6.6.1/wasm_singlethread/plugins/imageformats/libqsvg.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6Svg.a C:/Qt/6.6.1/wasm_singlethread/plugins/imageformats/libqtga.a C:/Qt/6.6.1/wasm_singlethread/plugins/imageformats/libqtiff.a C:/Qt/6.6.1/wasm_singlethread/plugins/imageformats/libqwbmp.a C:/Qt/6.6.1/wasm_singlethread/plugins/imageformats/libqwebp.a C:/Qt/6.6.1/wasm_singlethread/lib/objects-Release/Widgets_resources_1/.rcc/qrc_qstyle.cpp.o C:/Qt/6.6.1/wasm_singlethread/lib/objects-Release/Widgets_resources_2/.rcc/qrc_qstyle1.cpp.o C:/Qt/6.6.1/wasm_singlethread/lib/objects-Release/Widgets_resources_3/.rcc/qrc_qmessagebox.cpp.o C:/Qt/6.6.1/wasm_singlethread/lib/libQt6OpenGLWidgets.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6Widgets.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6OpenGL.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6Gui.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledHarfbuzz.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledFreetype.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledLibpng.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6Core.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledZLIB.a C:/Qt/6.6.1/wasm_singlethread/lib/libQt6BundledPcre2.a -LC:\emsdk-main\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten --whole-archive -lfetch -lembind-rtti --no-whole-archive -lGL-emu-webgl2 -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr C:\Users\14240\AppData\Local\Temp\tmpp490mddhlibemscripten_js_symbols.so --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=__main_argc_argv --export-if-defined=fflush --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=__cxa_demangle --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=malloc --export=free --export=__wasm_call_ctors --export-table -z stack-size=5242880 --initial-memory=52428800 --no-entry --max-memory=2147483648 --stack-first' failed (returned 1)
mingw32-make: *** [Makefile:69: .\Cpp-QtWidgetsApplication-Test.js] Error 1
10:47:05: 进程"C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe"退出,退出代码 2 。
Error while building/deploying project Cpp-QtWidgetsApplication-Test (kit: WebAssembly Qt 6.6.1 (single-threaded))
When executing step "Make"

There is a teaching program written with qt opengl low version before, want to transplant to the web, but the oepngl library, Mingw environment with the system opengl library can be used, Emscripten environment I should use which.

sbc100 commented 9 months ago

Interesting, it looks like we emulate glVertex3f but not glVertex3d: https://github.com/emscripten-core/emscripten/blob/a95c44ee924d02fa1498f846595485d27c31daa8/src/library_glemu.js#L3134-L3146

@juj do you remember if this was a deliberate choice?

kripken commented 9 months ago

In general the OpenGL API surface is very large and we've added things as needed, so probably a lot is still missing.

glVertex3d seems reasonable to add, a PR would be welcome.

juj commented 9 months ago

The GL emulation layer predates my time, I think it was developed by Alon and then another Mozilla developer Ehsan Akhgari. Like Alon writes above, the features grew bottom-up as needed to support what was needed to port the Cube3d(?) engine, or what was it called.

So if there is interest, people are more than welcome to contribute whatever they need to emulate more desktop GL features, but it's not being developed with any kind of completeness goal in mind.

Although I wonder if a better route might be to port that teaching program to work against modern OpenGL 3.0? (which has a good overlap with OpenGL ES 3.0 and WebGL 2) After all, the legacy desktop OpenGL is legacy, so it may be of little value to teach to anyone - unless the goal is to specifically teach vintage programming?