Skip to content

glNormal3f only works in immediate mode #24153

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

Open
TheBrokenRail opened this issue Apr 20, 2025 · 4 comments
Open

glNormal3f only works in immediate mode #24153

TheBrokenRail opened this issue Apr 20, 2025 · 4 comments

Comments

@TheBrokenRail
Copy link

TheBrokenRail commented Apr 20, 2025

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
@sbc100
Copy link
Collaborator

sbc100 commented Apr 21, 2025

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.

@kainino0x
Copy link
Collaborator

Unfortunately I don't know anything about the Desktop GL implementation (LEGACY_GL_EMULATION).

@juj
Copy link
Collaborator

juj commented Apr 22, 2025

When not using immediate mode, glNormal3f should behave similarly to glColor4f.

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:

emscripten/src/lib/libglemu.js

Lines 3238 to 3246 in d4a7433

} else {
GLImmediate.clientColor[0] = r;
GLImmediate.clientColor[1] = g;
GLImmediate.clientColor[2] = b;
GLImmediate.clientColor[3] = a;
#if GL_FFP_ONLY
GLctx.vertexAttrib4fv(GLImmediate.COLOR, GLImmediate.clientColor);
#endif
}

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.

@kripken
Copy link
Member

kripken commented Apr 22, 2025

There is also gl4es:

https://github.com/ptitSeb/gl4es

It mentions it has Emscripten support there, but I haven't tried it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants