Page 1 of 1

Linker errors while trying to use <SDL_opengl.h>

Posted: Sat Jun 15, 2024 1:44 pm
by brammie15
Hey,

I'm truing to use OpenGL with SDL in a project for the Switch,
I can get SDL to build / run on it. But when i try to use fucntions from SDL_opengl.h it causes linker errors.

Here is the code of what i am trying to build,
https://github.com/brammie15/SwitchEngine
And here is the error i keep getting

Code: Select all

linking application.elf
/opt/devkitpro/devkitA64/bin/../lib/gcc/aarch64-none-elf/14.1.0/../../../../aarch64-none-elf/bin/ld: main.o: in function `main':
/home/bart/Downloads/application/source/main.cpp:76:(.text.startup.main+0xb0): undefined reference to `glMatrixMode'
collect2: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/libnx/switch_rules:81: /home/bart/Downloads/application/application.elf] Error 1
make: *** [Makefile:171: build] Error 2
I have looked at the Opengl examples and tried to also add the libs from opengl but to no avail

Any help?

Re: Linker errors while trying to use <SDL_opengl.h>

Posted: Mon Jul 15, 2024 3:53 am
by Tenry
It appears the symbol glmatrixMode is not available in the library. You can check it using the nm command on libGLESv2.a:

Code: Select all

cd /opt/devkitpro/portlibs/switch/lib && nm libGLESv2.a | grep glMatrixMode
As far as I can tell this method is related to a legacy OpenGL with "immediate mode", which is not (fully) supported here, I believe. Instead, you should work with shaders and set matrices as uniforms using the

Code: Select all

glUniformMatrix4fv()
function.