mirror of
https://github.com/mpv-player/mpv
synced 2025-03-29 23:07:56 +00:00
gl_x11: always require some GLX API functions, avoid dlsym()
The functions glXGetProcAddressARB() and glXQueryExtensionsString() were loaded using dlsym(). This could fail when compiling to libmpv, because then dlopen(NULL, ...) will look in the main program's list of libraries, and the libGL linked to libmpv is never considered. (Don't know if this somehow could be worked around.) The result is that using vo_opengl with libmpv can fail. Avoid this by not using dlsym(). glXGetProcAddressARB() was already used directly in the same file, and that never caused any problems. (Still add it to the configure test.) glXQueryExtensionsString() is documented as added in GLX 1.1 - that's ancient.
This commit is contained in:
parent
9f6e8d64de
commit
8178b80748
@ -144,7 +144,7 @@ static bool is_software_gl(GL *gl)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
void *mp_getdladdr(const char *s)
|
||||
static void *mp_getdladdr(const char *s)
|
||||
{
|
||||
void *ret = NULL;
|
||||
#if HAVE_LIBDL
|
||||
|
@ -208,8 +208,6 @@ struct gl_hwdec_driver {
|
||||
|
||||
extern const struct gl_hwdec_driver *mpgl_hwdec_drivers[];
|
||||
|
||||
void *mp_getdladdr(const char *s);
|
||||
|
||||
void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *),
|
||||
const char *ext2, struct mp_log *log);
|
||||
|
||||
|
@ -62,18 +62,9 @@ static bool create_context_x11_old(struct MPGLContext *ctx)
|
||||
return false;
|
||||
}
|
||||
|
||||
void *(*getProcAddress)(const GLubyte *);
|
||||
getProcAddress = mp_getdladdr("glXGetProcAddress");
|
||||
if (!getProcAddress)
|
||||
getProcAddress = mp_getdladdr("glXGetProcAddressARB");
|
||||
const char *glxstr = glXQueryExtensionsString(display, ctx->vo->x11->screen);
|
||||
|
||||
const char *glxstr = "";
|
||||
const char *(*glXExtStr)(Display *, int)
|
||||
= mp_getdladdr("glXQueryExtensionsString");
|
||||
if (glXExtStr)
|
||||
glxstr = glXExtStr(display, ctx->vo->x11->screen);
|
||||
|
||||
mpgl_load_functions(gl, getProcAddress, glxstr, vo->log);
|
||||
mpgl_load_functions(gl, (void *)glXGetProcAddressARB, glxstr, vo->log);
|
||||
if (!gl->GenPrograms && gl->GetString &&
|
||||
gl->version < MPGL_VER(3, 0) &&
|
||||
strstr(gl->GetString(GL_EXTENSIONS), "GL_ARB_vertex_program"))
|
||||
@ -105,11 +96,8 @@ static bool create_context_x11_gl3(struct MPGLContext *ctx, bool debug)
|
||||
(glXCreateContextAttribsARBProc)
|
||||
glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB");
|
||||
|
||||
const char *glxstr = "";
|
||||
const char *(*glXExtStr)(Display *, int)
|
||||
= mp_getdladdr("glXQueryExtensionsString");
|
||||
if (glXExtStr)
|
||||
glxstr = glXExtStr(vo->x11->display, vo->x11->screen);
|
||||
const char *glxstr =
|
||||
glXQueryExtensionsString(vo->x11->display, vo->x11->screen);
|
||||
bool have_ctx_ext = glxstr && !!strstr(glxstr, "GLX_ARB_create_context");
|
||||
|
||||
if (!(have_ctx_ext && glXCreateContextAttribsARB)) {
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <GL/glx.h>
|
||||
#include <GL/gl.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
glXCreateContext(NULL, NULL, NULL, True);
|
||||
glXQueryExtensionsString(NULL, 0);
|
||||
glXGetProcAddressARB("");
|
||||
glFinish();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user