USE_REGAL does not link in GLU methods
I'm using Regal (for OpenGL 1 emulation) and SDL 1. I'm not pulling in GLU, even with the flags I would expect would work.
Flags:
CFLAGS := -s USE_REGAL=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0
LDFLAGS := -s USE_REGAL=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -lGL -lGLU
Output:
warning: undefined symbol: SDL_GetRelativeMouseState (referenced by top-level compiled C/C++ code)
warning: undefined symbol: gluBuild2DMipmaps (referenced by top-level compiled C/C++ code)
warning: undefined symbol: gluDeleteQuadric (referenced by top-level compiled C/C++ code)
warning: undefined symbol: gluLookAt (referenced by top-level compiled C/C++ code)
warning: undefined symbol: gluNewQuadric (referenced by top-level compiled C/C++ code)
warning: undefined symbol: gluPerspective (referenced by top-level compiled C/C++ code)
warning: undefined symbol: gluQuadricNormals (referenced by top-level compiled C/C++ code)
warning: undefined symbol: gluQuadricTexture (referenced by top-level compiled C/C++ code)
warning: undefined symbol: gluSphere (referenced by top-level compiled C/C++ code)
Without the ERROR_ON_UNDEFINED_SYMBOLS, there's obviously linking errors. With it, there's run-time exceptions thrown in the browser complaining about the missing symbols...
Is there anything I can do short of compiling and linking in a GLU library implementation myself, such as quad.c, etc. from Mesa? I can probably work around the missing SDL_GetRelativeMouseState as well just by subtracting absolute mouse state between frames, would be nice to have the original method though...
Nonetheless, I would have expected all of these to be included with emscripten with the above options. Can you please check to make sure I am not doing anything wrong?
Thanks a bunch for your help!!
We don't have a huge amount of testing for the Regal port in emscripten.
It looks like there are two tests in test_browser.py: test_sdl_ogl_regal test_cubegeom_pre_regal test_cubegeom_regal test_cubegeom_pre_vao_regal
These tests all work so I guess the undefined symbols here are coming either from your application code or from code paths in Regal itself that are not linked in in any of our tests?
At least some of those function listed such as gluPerspective and gluLookAt are defined in src/library_glemu.js which means that build with -sLEGACY_GL_EMULATION will probably help for some of these symbols.
For other symbols such as SDL_GetRelativeMouseState and gluSphere it does look like we are currently missing implementations. For SDL_GetRelativeMouseState it should be fairly straight forward to add an implementation to src/library_sdl.js. I'm not familiar with the undefined glu functions but it seems like they could be added src/library_glemu.js.
Before adding them it might be worth looking at where the reference is coming from. You can do this by linking with -Wl,--trace-symbol=gluSphere.
USE_REGAL=1 requires ES2 emulation so it's not compatible with legacy GL emulation.
Good news is that it does look like Regal itself has implementations for quadrics and spheres in src/glu/libutil/quad.c so it's just a question of modifying the regal package port Emscripten has to make sure this file is built and exported.
I will also look into porting SDL_GetRelativeMouseState to JS. SDL's C implementation just calls SDL_GetMouse() to set the output arguments. Easy peasy. For us, there is a relative mouse event coming from the Browser library we can just plug into.
Can keep digging this coming weekend again to send PRs...