summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Hopf <mat@mshopf.de>2008-08-08 17:18:32 +0200
committerMatthias Hopf <mat@mshopf.de>2008-08-08 17:18:32 +0200
commit9b70d5f03f02bb3497eb7291e9858e34388a9aa1 (patch)
treefe571158be6db0daf0b8db1466f15b14f532c64b /src
parent35b16971490c92f53cb5264e68ba67fb7352629a (diff)
downloadxine-lib-9b70d5f03f02bb3497eb7291e9858e34388a9aa1.tar.gz
xine-lib-9b70d5f03f02bb3497eb7291e9858e34388a9aa1.tar.bz2
video_out_opengl: Activate only if visual is direct rendering capable
Diffstat (limited to 'src')
-rw-r--r--src/video_out/video_out_opengl.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c
index 4aeaab325..d66e85ae9 100644
--- a/src/video_out/video_out_opengl.c
+++ b/src/video_out/video_out_opengl.c
@@ -1954,8 +1954,66 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
/*
* class functions
*/
+
+static int opengl_verify_direct (x11_visual_t *vis) {
+ int attribs[] = {
+ GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ None
+ };
+ Window root, win;
+ XVisualInfo *visinfo;
+ GLXContext ctx;
+ XSetWindowAttributes xattr;
+ int ret = 0;
+
+ if (!vis || !vis->display ||
+ ! (root = RootWindow (vis->display, vis->screen))) {
+ fprintf (stderr, "[videoout_opengl]: Don't have a root window to verify\n");
+ return 0;
+ }
+ if (! (visinfo = glXChooseVisual (vis->display, vis->screen, attribs)))
+ return 0;
+ if (! (ctx = glXCreateContext (vis->display, visinfo, NULL, 1)))
+ return 0;
+ memset (&xattr, 0, sizeof (xattr));
+ xattr.colormap = XCreateColormap(vis->display, root, visinfo->visual, AllocNone);
+ xattr.event_mask = StructureNotifyMask | ExposureMask;
+ if ( (win = XCreateWindow (vis->display, root, 0, 0, 1, 1, 0, visinfo->depth,
+ InputOutput, visinfo->visual,
+ CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
+ &xattr))) {
+ if (glXMakeCurrent (vis->display, win, ctx)) {
+ const char *renderer = (const char *) glGetString(GL_RENDERER);
+ if (glXIsDirect (vis->display, ctx) &&
+ ! strstr (renderer, "Software") &&
+ ! strstr (renderer, "Indirect"))
+ ret = 1;
+ glXMakeCurrent (vis->display, None, NULL);
+ }
+ XDestroyWindow (vis->display, win);
+ }
+ glXDestroyContext (vis->display, ctx);
+ XFreeColormap (vis->display, xattr.colormap);
+
+ return ret;
+}
+
static void *opengl_init_class (xine_t *xine, void *visual_gen) {
- opengl_class_t *this = (opengl_class_t *) calloc(1, sizeof(opengl_class_t));
+
+ opengl_class_t *this;
+
+ xprintf (xine, XINE_VERBOSITY_LOG,
+ "video_out_opengl: Testing for hardware accelerated direct rendering visual\n");
+ if (! opengl_verify_direct ((x11_visual_t *)visual_gen)) {
+ xprintf (xine, XINE_VERBOSITY_LOG,
+ "video_out_opengl: Didn't find any\n");
+ return NULL;
+ }
+
+ this = (opengl_class_t *) calloc (1, sizeof(opengl_class_t));
this->driver_class.open_plugin = opengl_open_plugin;
this->driver_class.identifier = "opengl";