mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-26 03:24:36 +00:00
Do not use SDL_SYM_WRAP outside sdl_ctx.c.
This commit is contained in:
parent
9f345b4483
commit
e1fc6d7ab5
@ -38,6 +38,11 @@ static SDL_Window *g_window;
|
||||
static SDL_GLContext g_ctx;
|
||||
#endif
|
||||
|
||||
#define GL_SYM_WRAP(symbol, proc) if (!symbol) { \
|
||||
gfx_ctx_proc_t sym = gfx_ctx_get_proc_address(proc); \
|
||||
memcpy(&(symbol), &sym, sizeof(sym)); \
|
||||
}
|
||||
|
||||
static bool g_fullscreen;
|
||||
static unsigned g_interval;
|
||||
|
||||
@ -55,7 +60,7 @@ void gfx_ctx_set_swap_interval(unsigned interval, bool inited)
|
||||
#if defined(_WIN32)
|
||||
static BOOL (APIENTRY *wgl_swap_interval)(int) = NULL;
|
||||
if (!wgl_swap_interval)
|
||||
SDL_SYM_WRAP(wgl_swap_interval, "wglSwapIntervalEXT");
|
||||
GL_SYM_WRAP(wgl_swap_interval, "wglSwapIntervalEXT");
|
||||
if (wgl_swap_interval)
|
||||
success = wgl_swap_interval(g_interval);
|
||||
#elif defined(__APPLE__) && defined(HAVE_OPENGL)
|
||||
@ -64,9 +69,9 @@ void gfx_ctx_set_swap_interval(unsigned interval, bool inited)
|
||||
#else
|
||||
static int (*glx_swap_interval)(int) = NULL;
|
||||
if (!glx_swap_interval)
|
||||
SDL_SYM_WRAP(glx_swap_interval, "glXSwapIntervalSGI");
|
||||
GL_SYM_WRAP(glx_swap_interval, "glXSwapIntervalSGI");
|
||||
if (!glx_swap_interval)
|
||||
SDL_SYM_WRAP(glx_swap_interval, "glXSwapIntervalMESA");
|
||||
GL_SYM_WRAP(glx_swap_interval, "glXSwapIntervalMESA");
|
||||
|
||||
if (glx_swap_interval)
|
||||
success = glx_swap_interval(g_interval) == 0;
|
||||
@ -458,5 +463,18 @@ void gfx_ctx_set_projection(gl_t *gl, const struct gl_ortho *ortho, bool allow_r
|
||||
|
||||
gl->mvp = proj;
|
||||
}
|
||||
|
||||
// Enforce void (*)(void) as it's not really legal to cast void* to fn-pointer.
|
||||
// POSIX allows this, but strict C99 doesn't.
|
||||
gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol)
|
||||
{
|
||||
rarch_assert(sizeof(void*) == sizeof(void (*)(void)));
|
||||
gfx_ctx_proc_t ret;
|
||||
|
||||
void *sym__ = SDL_GL_GetProcAddress(symbol);
|
||||
memcpy(&ret, &sym__, sizeof(void*));
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -25,11 +25,5 @@
|
||||
#define SDL_MODERN 0
|
||||
#endif
|
||||
|
||||
// Not legal to cast (void*) to fn-pointer. Need workaround to be compliant.
|
||||
#define SDL_SYM_WRAP(sym, symbol) { \
|
||||
rarch_assert(sizeof(void*) == sizeof(void (*)(void))); \
|
||||
void *sym__ = SDL_GL_GetProcAddress(symbol); \
|
||||
memcpy(&(sym), &sym__, sizeof(void*)); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -78,7 +78,9 @@ int gfx_ctx_check_resolution(unsigned resolution_id);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_D3D9) || defined(HAVE_D3D8)
|
||||
typedef void (*gfx_ctx_proc_t)(void);
|
||||
void gfx_ctx_set_projection(VID_HANDLE *gl, const struct gl_ortho *ortho, bool allow_rotate);
|
||||
gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *sym);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -890,7 +890,10 @@ static void gl_glsl_reset_attrib(void)
|
||||
gl_attrib_index = 0;
|
||||
}
|
||||
|
||||
#define LOAD_GL_SYM(SYM) if (!pgl##SYM) { SDL_SYM_WRAP(pgl##SYM, "gl" #SYM) }
|
||||
#define LOAD_GL_SYM(SYM) if (!pgl##SYM) { \
|
||||
gfx_ctx_proc_t sym = gfx_ctx_get_proc_address("gl" #SYM); \
|
||||
memcpy(&(pgl##SYM), &sym, sizeof(sym)); \
|
||||
}
|
||||
|
||||
bool gl_glsl_init(const char *path)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user