Skip to content

Commit

Permalink
ogc: define weak symbols for opengx functions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mardy committed Sep 26, 2024
1 parent c56247f commit 8d554f5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/video/ogc/SDL_ogcgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8d554f5

Please sign in to comment.