Revision: 76949
          http://sourceforge.net/p/brlcad/code/76949
Author:   starseeker
Date:     2020-08-25 20:58:11 +0000 (Tue, 25 Aug 2020)
Log Message:
-----------
Fix transparent display and framebuffer windows.

Some configurations of Linux desktops (including default Gnome setups
on Ubuntu and Redhat) have started using transparency by default. This
has resulted in an odd semi-transparent window for default ogl display
manger and framebuffer windows.

Fix this by adding a filter the X11 visual choosing functions that
rejects any window reporting an alpha mask.  With this filter the
selection returns opaque windows and restores the expected rendering
appearance.

Modified Paths:
--------------
    brlcad/trunk/CMakeLists.txt
    brlcad/trunk/src/libdm/glx/dm-ogl.c
    brlcad/trunk/src/libdm/glx/if_ogl.c

Modified: brlcad/trunk/CMakeLists.txt
===================================================================
--- brlcad/trunk/CMakeLists.txt 2020-08-25 18:44:56 UTC (rev 76948)
+++ brlcad/trunk/CMakeLists.txt 2020-08-25 20:58:11 UTC (rev 76949)
@@ -1294,6 +1294,9 @@
 # we've indicated we *don't* want an X11 build
 if(NOT BRLCAD_ENABLE_AQUA AND NOT BRLCAD_ENABLE_MINIMAL)
   include(FindX11)
+  if (X11_Xrender_FOUND)
+    CONFIG_H_APPEND(BRLCAD "#define HAVE_XRENDER 1\n")
+  endif (X11_Xrender_FOUND)
 endif(NOT BRLCAD_ENABLE_AQUA AND NOT BRLCAD_ENABLE_MINIMAL)
 
 # make sure Xi is included in the list of X11 libs

Modified: brlcad/trunk/src/libdm/glx/dm-ogl.c
===================================================================
--- brlcad/trunk/src/libdm/glx/dm-ogl.c 2020-08-25 18:44:56 UTC (rev 76948)
+++ brlcad/trunk/src/libdm/glx/dm-ogl.c 2020-08-25 20:58:11 UTC (rev 76949)
@@ -56,6 +56,9 @@
 #define remainder rem
 #ifdef HAVE_GL_GLX_H
 #  include <GL/glx.h>
+#  ifdef HAVE_XRENDER
+#    include <X11/extensions/Xrender.h>
+#  endif
 #endif
 #ifdef HAVE_GL_GL_H
 #  include <GL/gl.h>
@@ -547,6 +550,15 @@
            if (fail || !dbfr)
                continue;
 
+#ifdef HAVE_XRENDER
+           // https://stackoverflow.com/a/23836430
+           XRenderPictFormat *pict_format = 
XRenderFindVisualFormat(pubvars->dpy, vip->visual);
+           if(pict_format->direct.alphaMask > 0) {
+               //printf("skipping visual with alphaMask\n");
+               continue;
+           }
+#endif
+
            /* desires */
            if (m_zbuffer) {
                fail = glXGetConfig(pubvars->dpy,

Modified: brlcad/trunk/src/libdm/glx/if_ogl.c
===================================================================
--- brlcad/trunk/src/libdm/glx/if_ogl.c 2020-08-25 18:44:56 UTC (rev 76948)
+++ brlcad/trunk/src/libdm/glx/if_ogl.c 2020-08-25 20:58:11 UTC (rev 76949)
@@ -61,6 +61,9 @@
 #ifdef HAVE_GL_GLX_H
 #  define class REDEFINE_CLASS_STRING_TO_AVOID_CXX_CONFLICT
 #  include <GL/glx.h>
+#  ifdef HAVE_XRENDER
+#    include <X11/extensions/Xrender.h>
+#  endif
 #endif
 #undef remainder
 #undef access
@@ -923,6 +926,16 @@
            if (!rgba) {
                continue;
            }
+
+#ifdef HAVE_XRENDER
+           // https://stackoverflow.com/a/23836430
+           XRenderPictFormat *pict_format = 
XRenderFindVisualFormat(OGL(ifp)->dispp, vip->visual);
+           if(pict_format->direct.alphaMask > 0) {
+               //printf("skipping visual with alphaMask\n");
+               continue;
+           }
+#endif
+
            /* desires */
            /* X_CreateColormap needs a DirectColor visual */
            /* There should be some way of handling this with TrueColor,

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to