glXChooseVisual problem with True vs Direct color

Hi - I am forwarding a question from one of our users who is using OpenGL. I personally am not a coder, but I manage the linux system that he’s using, Can anyone give me a clue as to what problem might be? Thanks:

"I’m having a problem with glXChooseVisual:

I’m ssh’ing from my Redhat linux (RHEL5) workstation, into another machine. Well the point is that the display on my Redhat linux workstation has numerous visuals that are TrueColor (24 depth) as reported by xdpyinfo. The GL specification says that TrueColor should be preferred to DirectColor by the glXChooseVisual. Nevertheless, the display chooses the DirectColor visual even though it is otherwise identical to the TrueColor visuals. The result is that there are flashing color maps and other problems (because TrueColor is being used by the Window manager etc). This does not happen running this program from other machines, such as my laptop which has a different display and X driver."

Any clue to how I can debug this problem? Thanks. - Mark

This is testing my memory (been a long time since the X11 PseudoColor days :slight_smile: ), but if you are seeing colormap flashing, that means that there is contention for a shared color map.

Look at a window where you are seeing colormap flashing. Use xwininfo (run it and then click on the window) to print out the Visual Class of that application. To see colormap flashing, presumably there are multiple apps using a non-TrueColor visual (e.g. PseudoColor). Figure out what these apps are. Also run it on your user’s application to verify that it is in-fact running in the Visual Class you think it is. Also run it by clicking on the root window (desktop background) and verify that it is TrueColor.

While your user “can” use glXChooseVisual, IIRC it doesn’t quite give you the control you want for specifying the Visual Class you’d like to have. I’d suggest using glXChooseFBConfig and glXGetVisualFromFBConfig instead.

For instance (glXChooseVisual example):

  int attribs [] = { GLX_RGBA,
                     GLX_RED_SIZE, 8,
                     GLX_GREEN_SIZE, 8,
                     GLX_BLUE_SIZE, 8,
                     GLX_DEPTH_SIZE, 24,
                     GTX_STENCIL_SIZE 8,
                     None };

  visual_info = glXChooseVisual ( display, screen, attribs );

there is nothing here that says “I want a true color visual” (i.e. no colormap!)

Whereas with glXChooseFBConfig, you can be very specific about that:

  int attribs[] =
      GLX_X_RENDERABLE    , True,
      GLX_RED_SIZE        , 8,
      GLX_GREEN_SIZE      , 8,
      GLX_BLUE_SIZE       , 8,
      GLX_ALPHA_SIZE      , 8,
      GLX_DEPTH_SIZE      , 24,
      GLX_STENCIL_SIZE    , 8,
      GLX_DOUBLEBUFFER    , True,

  GLXFBConfig ret = 0;

  int fbcount;
  GLXFBConfig *fbc = glXChooseFBConfig( getXDisplay(), getXScreen(), 
                                        attribs, &fbcount );

  if ( fbc )
    if ( fbcount >= 1 )
      my_fbc = fbc[0];

    XFree( fbc );

   visual_info = glXGetVisualFromFBConfig( display, my_fbc );

In either case, you can print visual_info->visualid in hex (%x) to the console, and cross-reference it to a specific line in “glxinfo” output to see exactly which visual you received and what its capabilities are (visual cl == tc implies TrueColor, == dc implies DirectColor).