Graphics 版 (精华区)
发信人: dcs (euraka), 信区: Graphics
标 题: Motif&Opengl(4)
发信站: 紫 丁 香 (Mon Mar 29 21:41:27 1999), 转信
2.1 The OpenGL-specific Widget
There are two OpenGL-specific drawing area widget classes. One is derived from the Motif primitive widget class (not the Motif drawing area widget class). The other is derived from the X Toolkit core widget class. Both have the same basic functionality;
the main difference is that the Motif-based widget class gains capabilities of the Motif primitive widget class. If you use Motif, you should use the Motif OpenGL widget. If you use a non-Motif widget set, you can use the second widget for identical
functionality.
The Motif OpenGL widget class is named glwMDrawingAreaWidgetClass; the non-Motif OpenGL widget class is named glwDrawingAreaWidgetClass (the difference is the lack of an M in the non-Motif case). Since the Motif OpenGL widget is subclassed from the
Motif primitive widget class, the Motif OpenGL widget inherits the capabilities of the primitive class like a help callback and keyboard traversal support (keyboard traversal is disabled by default for the Motif OpenGL widget). The paperplane example
uses the Motif widget by default but the non-Motif widget can be used by defining the noMotifGLwidget C preprocessor symbol when compiling paperplane.c. The difference is two changed lines of code with no functional difference in the program.
When you create either type of widget, you need to specify the visual to use by supplying the widget's GLwNvisualInfo resource. The attribute is of type XVisualInfo* making it easy to find an appropriate visual using glXChooseVisual which returns a
XVisualInfo* for a visual with the capabilities you request.
Although this practice is not recommended, the widgets also allow you to specify the OpenGL capabilities you desire for the widget directly using widget resources. Because the X Toolkit widget creation process is not expected to fail, there is no way
for a widget creation routine to indicate failure. If a visual that matches the desired OpenGL capabilities cannot be found, the widget code prints an error and exits without giving the program a chance to handle the failure. If you request a specific
XVisualInfo* that has already been determined to be acceptable using glXChooseVisual or calls to glXGetConfig, you will not have this problem. As a rule, always specify the visual using the GLwNvisualInfo resource.
The OpenGL widgets also do extra work that might go unnoticed. Because the OpenGL widget uses a different visual, the widget's creation code creates a colormap matching the visual. It also posts an ICCCM WM_COLORMAP_WINDOWS top level window property to
let the window manager know that the program uses multiple colormaps.
More information about the OpenGL widgets can be found in the Silicon Graphics OpenGL Porting Guide [4] and the widgets' man pages.
--
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: 202.118.239.121]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.553毫秒