From abdd055665932fcd9043a16e8c3b37b4262e846e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Sun, 13 Jun 2010 23:05:37 +0000 Subject: [PATCH] Allow direct rendering with GLX versions older than 1.3 if the GLX extensions list includes "GLX_EXT_texture_from_pixmap". BUG: 240956 svn path=/trunk/KDE/kdebase/workspace/; revision=1137668 --- opengltest/opengltest.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/opengltest/opengltest.cpp b/opengltest/opengltest.cpp index 78ebfff3ea..d2d8f70b9b 100644 --- a/opengltest/opengltest.cpp +++ b/opengltest/opengltest.cpp @@ -37,11 +37,6 @@ int main(int argc, char *argv[]) if (!glXQueryVersion(dpy, &major, &minor)) return 1; - // glXCreatePixmap() is a GLX 1.3+ function. - // It is also provided by EXT_texture_from_pixmap, but only for indirect contexts. - if (major == 1 && minor < 3) - return 1; - int attribs[] = { GLX_RGBA, GLX_RED_SIZE, 1, @@ -62,7 +57,10 @@ int main(int argc, char *argv[]) if (!xvi) return 1; + // Create a direct rendering context GLXContext ctx = glXCreateContext(dpy, xvi, NULL, True); + if (!glXIsDirect(dpy, ctx)) + return 1; // Create a window using the visual. // We only need it to make the context current @@ -73,9 +71,17 @@ int main(int argc, char *argv[]) Window win = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1, 1, 0, xvi->depth, InputOutput, xvi->visual, CWBackPixel | CWBorderPixel | CWColormap, &attr); - glXMakeCurrent(dpy, win, ctx); - // Assume that glXCreatePixmap() works with DRI2 drivers + // Try to make the context current + if (!glXMakeCurrent(dpy, win, ctx)) + return 1; + + // glXCreatePixmap() is a GLX 1.3+ function, but it's also provided by EXT_texture_from_pixmap + const char *glxExtensions = glXQueryExtensionsString(dpy, DefaultScreen(dpy)); + if ((major == 1 && minor < 3) && !strstr(glxExtensions, "GLX_EXT_texture_from_pixmap")) + return 1; + + // Assume that direct rendering works with DRI2 drivers const GLubyte *renderer = glGetString(GL_RENDERER); if (strstr((const char *)renderer, "DRI2")) return 0;