From f1d45730bfcf668b4352ded0e1f1f1c722898e19 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Sat, 28 Sep 2024 23:08:18 +0300 Subject: [PATCH] ogc: define weak symbols for opengx functions (#82) This allows building a client application without linking to opengx, if the client itself does not need OpenGL. The opengx functions used by SDL are defined as weak, so that they will be used only if a strong symbol is not found during linking. $ nm /opt/devkitpro/portlibs/wii/lib/libSDL2.a | grep ogx 00000000 W ogx_get_proc_address 00000000 W ogx_initialize Partial fix for #81 --- src/video/ogc/SDL_ogcgl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/video/ogc/SDL_ogcgl.c b/src/video/ogc/SDL_ogcgl.c index 65035af20642c..d2270110e33eb 100644 --- a/src/video/ogc/SDL_ogcgl.c +++ b/src/video/ogc/SDL_ogcgl.c @@ -35,6 +35,21 @@ typedef struct int swap_interval; } OGC_GL_Context; +/* Weak symbols for the opengx functions used by SDL, so that the client does + * not need to link to opengx, unless it actually uses OpenGL. */ +void __attribute__((weak)) ogx_initialize(void) +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); +} + +void __attribute__((weak)) *ogx_get_proc_address(const char *) +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); + return NULL; +} + int SDL_OGC_GL_LoadLibrary(_THIS, const char *path) { return 0;