Resizing OpenGL widgets in Motif

From Higher Intellect Wiki
Jump to: navigation, search

I work on an SGI Indigo, running IRIX 5.3.

My problem is as follows:

I have an OpenGL widget and a Row/Column widget side by side in a form widget (the OpenGL widget is on the left). During execution I want to toggle between this layout and one in which the OpenGL widget occupies the whole form. I tried the following technique: originally, the OpenGL widget has the resource XmNrightAttachment set to XmATTACH_WIDGET and XmNrightWidget set to the row/column widget. Then I set XmNrightAttachment to XmATTACH_FORM and call XtUnmanageChild for the row/column widget. This doesn't work: it seems that the OpenGL window does indeed grow (the area where the row/column widget used to be begins to swap buffers along with the rest of the OpenGL window). But no OpenGL rendering takes place in this area, and neither is it cleared by glClear.


Generally, Motif widgets resize in response to geometry management from ancestor manager widgets. That is to say that the Motif library actually does the resizing of widget subwindows.

In this case, you need to actually make sure that you have called glXWaitX to make sure that Motif resize requests occur before OpenGL requests happen. Otherwise, your glViewport can execute "before" the XResizeWindow request (remember the OpenGL and X command streams execute independently and are buffered).

You'll find this issue discussed in my book "Programming OpenGL for the X Window System" (Addison-Wesley, ISBN 0-201-48359-9). See:

See pages 100-102 and 117.

What I do:

XGetWindowAttributes(); // just to get the new size of the widget

If you use gluPerspective(), you'll need to call this again with the new aspect ratio for your 'grown' GLX widget.

Share your opinion