Opengl, Motif and Xlib - resize callback - Motif

This is a discussion on Opengl, Motif and Xlib - resize callback - Motif ; Hello Group, I am trying to learn how to use OpenGL with the X-Windows system. I have a problem with my program in that the resize callback is never called. I have attached the most simple example of my problem. ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Opengl, Motif and Xlib - resize callback

  1. Opengl, Motif and Xlib - resize callback

    Hello Group,

    I am trying to learn how to use OpenGL with the X-Windows system. I
    have a problem with my
    program in that the resize callback is never called. I have attached
    the most simple example
    of my problem.

    Could it be explained as to what I am doing wrong that is causing the
    resize callback not
    to be called.

    Thanks

    Stuart

    #include
    #include
    #include
    #include
    #include
    #include
    #include

    static int snglBuf[] = {GLX_RGBA, GLX_DEPTH_SIZE, 16, None};
    static int dblBuf[] = {GLX_RGBA, GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER,
    None};

    GLXContext cx;
    Display *dpy;
    XtAppContext app;
    Widget toplevel, form, glxarea;

    void resize (Widget w, XtPointer clientData, XtPointer callData)
    {

    int width;
    int height;
    GLwDrawingAreaCallbackStruct *callbackData;
    callbackData = (GLwDrawingAreaCallbackStruct *) callData;
    printf("Resize %d Callback width is %d, Callback height is %d\n",
    w, callbackData->width, callbackData->height
    );

    }
    void expose (Widget w, XtPointer clientData, XtPointer callData)
    {
    GLwDrawingAreaCallbackStruct *callbackData;
    callbackData = (GLwDrawingAreaCallbackStruct *) callData;
    printf("Expose Callback width is %d, Callback height is %d\n",
    callbackData->width, callbackData->height);
    }

    int main(int argc, char *argv[])
    {
    XVisualInfo *vi;

    Arg args[10];
    Cardinal n;

    XtToolkitInitialize();

    app = XtCreateApplicationContext();

    dpy = XtOpenDisplay (app, NULL, "Test", "Test", NULL, 0, &argc,
    argv);

    n=0;
    XtSetArg(args[n], XmNtitle, "Bitmap Viewer"); n++;

    toplevel = XtAppCreateShell("shell", "shell",
    applicationShellWidgetClass, dpy, args, n);

    vi = glXChooseVisual(dpy, DefaultScreen(dpy), dblBuf);
    if (vi == NULL)
    {
    vi = glXChooseVisual(dpy, DefaultScreen(dpy), snglBuf);
    if (vi == NULL) XtAppError(app, "no RGB visual with depth
    buffer");
    }
    cx = glXCreateContext(dpy, vi, None, GL_TRUE);
    if (cx == NULL) XtAppError(app, "could not create rendering
    context");

    n=0;
    form = XtCreateWidget("form",xmFormWidgetClass, toplevel, args,
    n);
    XtManageChild(form);

    n=0;
    XtSetArg(args[n], GLwNvisualInfo, vi );n++;
    XtSetArg(args[n], XmNwidth, 800); n++;
    XtSetArg(args[n], XmNheight, 400); n++;

    glxarea = XtCreateWidget("glxarea", glwMDrawingAreaWidgetClass,
    form, args, n);
    XtAddCallback (glxarea, XmNresizeCallback, resize, NULL);
    XtAddCallback (glxarea, XmNexposeCallback, expose, NULL);

    XtManageChild(glxarea);

    XtRealizeWidget(toplevel);

    glXMakeCurrent(dpy, XtWindow(glxarea), cx);

    XtAppMainLoop(app);
    }

  2. Re: Opengl, Motif and Xlib - resize callback

    Stuart Norris wrote:
    > Hello Group,
    >
    > I am trying to learn how to use OpenGL with the X-Windows system. I
    > have a problem with my
    > program in that the resize callback is never called. I have attached
    > the most simple example
    > of my problem.
    >
    > Could it be explained as to what I am doing wrong that is causing the
    > resize callback not
    > to be called.
    >
    > Thanks
    >
    > Stuart
    >
    > [...]


    Could it be that your glxWidget is never resized, instead only the
    parent widget is resized? Check out The XmN{left, right, top, bottom}Attachment
    attributes e.g. "XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET);"

    Regards,

    Toni

    --
    for mail, mirror: ed.lausivksa@elielb

+ Reply to Thread