mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
vo_opengl: cleanup swap_control extension loading
Instead of somehow looking for the substring "_swap_control" and trying to several arbitrary function names, do it cleanly. The old approach has the problem that it's not very exact, and may even load a pointer to a function which doesn't exist. (Some GL implementations like Mesa return function pointers even the functions which don't exist, and calling them crashes.) I couldn't find any evidence that glXSwapInterval, wglSwapIntervalSGI, or wglSwapInterval actually exist, so don't include them. They were carried over from MPlayer times. To make diagnostics easier, print a warning in verbose mode if the function could not be loaded.
This commit is contained in:
@@ -243,13 +243,19 @@ static const struct gl_functions gl_functions[] = {
|
||||
.provides = MPGL_CAP_TEX_RG,
|
||||
},
|
||||
// Swap control, always an OS specific extension
|
||||
// The OSX code loads this manually.
|
||||
{
|
||||
.extension = "_swap_control",
|
||||
.extension = "GLX_SGI_swap_control",
|
||||
.functions = (const struct gl_function[]) {
|
||||
DEF_FN_NAMES(SwapInterval, "glXSwapIntervalSGI", "glXSwapInterval",
|
||||
"wglSwapIntervalSGI", "wglSwapInterval",
|
||||
"wglSwapIntervalEXT"),
|
||||
{0}
|
||||
DEF_FN_NAMES(SwapInterval, "glXSwapIntervalSGI"),
|
||||
{0},
|
||||
},
|
||||
},
|
||||
{
|
||||
.extension = "WGL_EXT_swap_control",
|
||||
.functions = (const struct gl_function[]) {
|
||||
DEF_FN_NAMES(SwapInterval, "wglSwapIntervalEXT"),
|
||||
{0},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -463,8 +463,11 @@ static int preinit(struct vo *vo)
|
||||
|
||||
mpgl_lock(p->glctx);
|
||||
|
||||
if (p->gl->SwapInterval)
|
||||
if (p->gl->SwapInterval) {
|
||||
p->gl->SwapInterval(p->swap_interval);
|
||||
} else {
|
||||
MP_VERBOSE(vo, "swap_control extension missing.\n");
|
||||
}
|
||||
|
||||
p->renderer = gl_video_init(p->gl, vo->log);
|
||||
if (!p->renderer)
|
||||
|
||||
Reference in New Issue
Block a user