`glNormal3f` only works in immediate mode
When using LEGACY_GL_EMULATION, glNormal3f crashes when not using glBegin/End. When not using immediate mode, glNormal3f should behave similarly to glColor4f.
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.7 (8dc91db45bf96c174531006839472a3924d105aa)
clang version 21.0.0git (https:/github.com/llvm/llvm-project 57025b42c43b2f14f7e58692bc19cd53d1b8a45e)
Target: wasm32-unknown-emscripten
Thread model: posix
Full link command and output with -v appended:
em++ -Wno-pthreads-mem-growth -sALLOW_MEMORY_GROWTH=1 -pthread -sEXPORTED_FUNCTIONS=_main,_resize_from_js -sEXPORTED_RUNTIME_METHODS=ccall --use-preload-plugins --preload-file /home/connor/Documents/ReMinecraftPE/game@/ -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sLEGACY_GL_EMULATION -sGL_FFP_ONLY -sUSE_ZLIB=1 -sUSE_SDL=2 platforms/sdl/CMakeFiles/reminecraftpe.dir/main.cpp.o platforms/sdl/CMakeFiles/reminecraftpe.dir/base/AppPlatform_sdl_base.cpp.o platforms/sdl/CMakeFiles/reminecraftpe.dir/emscripten/AppPlatform_sdl.cpp.o -o reminecraftpe.js source/libreminecraftpe-core.a platforms/sound/openal/libreminecraftpe-sound.a source/libreminecraftpe-core.a source/raknet/libraknet.a -lGL -lopenal
If you have a proposed fix then a PR would be most welcome. I'm not sure how easy this would be but perhaps you are right and it could be made to work in a similar fashion to glColor4f?
@kainino0x and @juj may know more.
Unfortunately I don't know anything about the Desktop GL implementation (LEGACY_GL_EMULATION).
When not using immediate mode,
glNormal3fshould behave similarly toglColor4f.
I presume the idea is that there would be a single constant normal value that all vertices would share? In your link, that is what glColor4f without glBegin() seems to do:
https://github.com/emscripten-core/emscripten/blob/d4a74336f23214bf3304d9eb0d03966786b30a36/src/lib/libglemu.js#L3238-L3246
The original authors of GL emulation path from Mozilla have long moved on, and the legacy GL emulation path does not have a maintainer. If you are interested in trying to develop a fix, then I'm sure we would be able to merge it - though there's not much activity with the legacy GL path in general.
There is a Regal port that might work better than the JS based legacy GL emulation: https://github.com/emscripten-ports/regal although that hasn't been updated in 6 years. It seems like the Regal website no longer exists either.
There is also gl4es:
https://github.com/ptitSeb/gl4es
It mentions it has Emscripten support there, but I haven't tried it myself.