Commit c9664a24 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

GLX: drop support for GLX version 1.2

This is useless as we require OpenGL 1.4.
parent 9fc6fc4b
...@@ -68,7 +68,6 @@ struct vout_display_sys_t ...@@ -68,7 +68,6 @@ struct vout_display_sys_t
xcb_window_t window; /* drawable X window */ xcb_window_t window; /* drawable X window */
xcb_window_t glwin; /* GLX window */ xcb_window_t glwin; /* GLX window */
bool visible; /* whether to draw */ bool visible; /* whether to draw */
bool v1_3; /* whether GLX >= 1.3 is available */
GLXContext ctx; GLXContext ctx;
vlc_gl_t gl; vlc_gl_t gl;
...@@ -151,7 +150,7 @@ FindWindow (vout_display_t *vd, xcb_connection_t *conn, ...@@ -151,7 +150,7 @@ FindWindow (vout_display_t *vd, xcb_connection_t *conn,
return screen; return screen;
} }
static bool CheckGLX (vout_display_t *vd, Display *dpy, bool *restrict pv13) static bool CheckGLX (vout_display_t *vd, Display *dpy)
{ {
int major, minor; int major, minor;
bool ok = false; bool ok = false;
...@@ -162,13 +161,12 @@ static bool CheckGLX (vout_display_t *vd, Display *dpy, bool *restrict pv13) ...@@ -162,13 +161,12 @@ static bool CheckGLX (vout_display_t *vd, Display *dpy, bool *restrict pv13)
if (major != 1) if (major != 1)
msg_Dbg (vd, "GLX extension version %d.%d unknown", major, minor); msg_Dbg (vd, "GLX extension version %d.%d unknown", major, minor);
else else
if (minor < 2) if (minor < 3)
msg_Dbg (vd, "GLX extension version %d.%d too old", major, minor); msg_Dbg (vd, "GLX extension version %d.%d too old", major, minor);
else else
{ {
msg_Dbg (vd, "using GLX extension version %d.%d", major, minor); msg_Dbg (vd, "using GLX extension version %d.%d", major, minor);
ok = true; ok = true;
*pv13 = minor >= 3;
} }
return ok; return ok;
} }
...@@ -246,7 +244,7 @@ static int Open (vlc_object_t *obj) ...@@ -246,7 +244,7 @@ static int Open (vlc_object_t *obj)
sys->conn = conn; sys->conn = conn;
sys->ctx = NULL; sys->ctx = NULL;
if (!CheckGLX (vd, dpy, &sys->v1_3)) if (!CheckGLX (vd, dpy))
goto error; goto error;
RegisterMouseEvents (obj, conn, sys->embed->handle.xid); RegisterMouseEvents (obj, conn, sys->embed->handle.xid);
...@@ -263,110 +261,75 @@ static int Open (vlc_object_t *obj) ...@@ -263,110 +261,75 @@ static int Open (vlc_object_t *obj)
sys->window = xcb_generate_id (conn); sys->window = xcb_generate_id (conn);
/* Determine our pixel format */ /* Determine our pixel format */
if (sys->v1_3) static const int attr[] = {
{ /* GLX 1.3 */ GLX_RED_SIZE, 5,
static const int attr[] = { GLX_GREEN_SIZE, 5,
GLX_RED_SIZE, 5, GLX_BLUE_SIZE, 5,
GLX_GREEN_SIZE, 5, GLX_DOUBLEBUFFER, True,
GLX_BLUE_SIZE, 5, GLX_X_RENDERABLE, True,
GLX_DOUBLEBUFFER, True, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_X_RENDERABLE, True, None
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, };
None };
xcb_get_window_attributes_reply_t *wa =
xcb_get_window_attributes_reply (conn,
xcb_get_window_attributes (conn, sys->embed->handle.xid),
NULL);
if (wa == NULL)
goto error;
xcb_visualid_t visual = wa->visual;
free (wa);
int nelem;
GLXFBConfig *confs = glXChooseFBConfig (dpy, snum, attr, &nelem);
if (confs == NULL)
{
msg_Err (vd, "no GLX frame buffer configurations");
goto error;
}
GLXFBConfig conf;
bool found = false;
for (int i = 0; i < nelem && !found; i++) xcb_get_window_attributes_reply_t *wa =
{ xcb_get_window_attributes_reply (conn,
conf = confs[i]; xcb_get_window_attributes (conn, sys->embed->handle.xid), NULL);
if (wa == NULL)
goto error;
xcb_visualid_t visual = wa->visual;
free (wa);
XVisualInfo *vi = glXGetVisualFromFBConfig (dpy, conf); int nelem;
if (vi == NULL) GLXFBConfig *confs = glXChooseFBConfig (dpy, snum, attr, &nelem);
continue; if (confs == NULL)
{
msg_Err (vd, "no GLX frame buffer configurations");
goto error;
}
if (vi->visualid == visual) GLXFBConfig conf;
found = true; bool found = false;
XFree (vi);
}
XFree (confs);
if (!found) for (int i = 0; i < nelem && !found; i++)
{ {
msg_Err (vd, "no matching GLX frame buffer configuration"); conf = confs[i];
goto error;
}
sys->glwin = None; XVisualInfo *vi = glXGetVisualFromFBConfig (dpy, conf);
if (!CreateWindow (vd, conn, depth, 0 /* ??? */, width, height)) if (vi == NULL)
sys->glwin = glXCreateWindow (dpy, conf, sys->window, NULL ); continue;
if (sys->glwin == None)
{
msg_Err (vd, "cannot create GLX window");
goto error;
}
/* Create an OpenGL context */ if (vi->visualid == visual)
sys->ctx = glXCreateNewContext (dpy, conf, GLX_RGBA_TYPE, NULL, found = true;
True); XFree (vi);
if (sys->ctx == NULL) }
{ XFree (confs);
msg_Err (vd, "cannot create GLX context");
goto error;
}
if (!glXMakeContextCurrent (dpy, sys->glwin, sys->glwin, sys->ctx)) if (!found)
goto error; {
msg_Err (vd, "no matching GLX frame buffer configuration");
goto error;
} }
else
{ /* GLX 1.2 */
int attr[] = {
GLX_RGBA,
GLX_RED_SIZE, 5,
GLX_GREEN_SIZE, 5,
GLX_BLUE_SIZE, 5,
GLX_DOUBLEBUFFER,
None };
XVisualInfo *vi = glXChooseVisual (dpy, snum, attr);
if (vi == NULL)
{
msg_Err (vd, "cannot find GLX 1.2 visual" );
goto error;
}
msg_Dbg (vd, "using GLX visual ID 0x%"PRIx32, (uint32_t)vi->visualid);
if (CreateWindow (vd, conn, depth, 0 /* ??? */, width, height) == 0) sys->glwin = None;
sys->ctx = glXCreateContext (dpy, vi, 0, True); if (!CreateWindow (vd, conn, depth, 0 /* ??? */, width, height))
XFree (vi); sys->glwin = glXCreateWindow (dpy, conf, sys->window, NULL );
if (sys->ctx == NULL) if (sys->glwin == None)
{ {
msg_Err (vd, "cannot create GLX context"); msg_Err (vd, "cannot create GLX window");
goto error; goto error;
} }
if (glXMakeCurrent (dpy, sys->window, sys->ctx) == False) /* Create an OpenGL context */
goto error; sys->ctx = glXCreateNewContext (dpy, conf, GLX_RGBA_TYPE, NULL, True);
sys->glwin = sys->window; if (sys->ctx == NULL)
{
msg_Err (vd, "cannot create GLX context");
goto error;
} }
if (!glXMakeContextCurrent (dpy, sys->glwin, sys->glwin, sys->ctx))
goto error;
const char *glx_extensions = glXQueryExtensionsString (dpy, snum); const char *glx_extensions = glXQueryExtensionsString (dpy, snum);
bool is_swap_interval_set = false; bool is_swap_interval_set = false;
...@@ -450,13 +413,9 @@ static void Close (vlc_object_t *obj) ...@@ -450,13 +413,9 @@ static void Close (vlc_object_t *obj)
if (sys->ctx != NULL) if (sys->ctx != NULL)
{ {
if (sys->v1_3) glXMakeContextCurrent (dpy, None, None, NULL);
glXMakeContextCurrent (dpy, None, None, NULL);
else
glXMakeCurrent (dpy, None, NULL);
glXDestroyContext (dpy, sys->ctx); glXDestroyContext (dpy, sys->ctx);
if (sys->v1_3) glXDestroyWindow (dpy, sys->glwin);
glXDestroyWindow (dpy, sys->glwin);
} }
XCloseDisplay (dpy); XCloseDisplay (dpy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment