[vtk-developers] Possible bug with vtkActor2D or with text actors.

Hank Childs childs at hyper.llnl.gov
Wed Oct 17 16:47:42 EDT 2001


> After some painstaking debugging I think I found a bug in the
> vtkActor2D/vtkTextActor.  I tested this with both a VTK 4.0 build
> (built on 6th August) and an older vtk 3.2 build.  Here is a
> description of the problem:

>     Program received signal SIGSEGV, Segmentation fault.
>     0x41b230c4 in __glXUseXFont () from /usr/lib/libGL.so.1
>     (gdb) back
>     #0  0x41b230c4 in __glXUseXFont () from /usr/lib/libGL.so.1
>     #1  0x41b1f1db in glXUseXFont () from /usr/lib/libGL.so.1
> 

Prabhu-

I have a related story.  I have had VTK programs hang when I have a
vtkScalarBar (ScalarBar->TextMapper) involved and I am running on a DEC
and displaying to an SGI.  I attached to it with a debugger and it was
stuck in glXUseXFont.  All other OS permutations I have tried (running on
DEC displaying to Linux, running on Linux displaying to SGI) work fine.

I was able to get it down to a 100 line program that was strictly X and
OpenGL.  I am still not sure whose X bug it is (Dec or SGI). It is
below if you want to see if that causes you problems as well.  Again,
my program hangs and does not seg fault. 

So: maybe helpful, maybe not.  If it does fail, it could take the blame
off VTK.

Best regards,
Hank


__________________________________________________________________________

#include <GL/glx.h>
#include <GL/gl.h>
#include <unistd.h>

#include <iostream.h>
static int attributeListSgl[] = { GLX_RGBA, GLX_RED_SIZE, 1, 
         /*get the deepest buffer with 1 red bit*/ GLX_GREEN_SIZE, 1,
          GLX_BLUE_SIZE,  1,  None };

static Bool WaitForNotify(Display *d, XEvent *e, char *arg)
{
    return (e->type == MapNotify) && (e->xmap.window == (Window)arg); 
}

Display *globaldpy = NULL;
void checker(char *);
int main(int argc, char **argv)
{
    Display *dpy;
    XVisualInfo *vi;
    Colormap cmap;
    XSetWindowAttributes swa;
    Window win;
    GLXContext cx;
    XEvent event;
    int swap_flag = FALSE;

    /* get a connection */
    dpy = XOpenDisplay(0);
    globaldpy = dpy;

    /* get an appropriate visual */
    vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributeListSgl);
    if (vi == NULL) {
       cerr << "Cannot make a visual." << endl;
       exit(1);
    }

    /* create a GLX context */
    cx = glXCreateContext(dpy, vi, 0, GL_TRUE);

    /* create a color map */
    cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen),
                           vi->visual, AllocNone);

    /* create a window */
    swa.colormap = cmap;
    swa.border_pixel = 0;
    swa.event_mask = StructureNotifyMask;
    win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 100, 100,
                        0, vi->depth, InputOutput, vi->visual,
                        CWBorderPixel|CWColormap|CWEventMask, &swa);
    XMapWindow(dpy, win);
    XIfEvent(dpy, &event, WaitForNotify, (char*)win);

    /* connect the context to the window */
    checker("Before making current");
    glXMakeCurrent(dpy, win, cx);
    checker("After making current");

    /* clear the buffer */
    glClearColor(1,1,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();

    /* wait a while */
    sleep(10); 
}


void checker(char *location)
{
    char  **fn;
    int     cnt;

    cerr << endl << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
    cerr << "At location: " << location << endl;

    cerr << "Calling XListFonts" << endl;
    fn = XListFonts(globaldpy, "*helvetica-bold-o-*-80-*", 1, &cnt);   
    cerr << "Done calling XListFonts." << endl;

    Font font = XLoadFont(globaldpy, fn[0]);
    glXUseXFont(font, 0, 255, 1000);

    cerr << "Calling XListFonts after glXUseXFont." << endl;
    fn = XListFonts(globaldpy, "*helvetica-bold-o-*-80-*", 1, &cnt);
    cerr << "Done calling X list fonts after glXUseXFont." << endl;

    cerr << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
}





More information about the vtk-developers mailing list