Debian Codegraph @

debian/external_deps/fetk/sg/src/glw/GLWDRAR.MAN

raw
1
2
3
4 GLwDrawingArea(3X) GLwDrawingArea(3X)
5
6
7
8 NAME
9 GLwDrawingArea, GLwMDrawingArea - OpenGL drawing widgets.
10
11
12 SYNOPSIS
13 #include <GL/GLwDrawA.h>
14 ld ... -lGLw -l<anywidgetlibrary> -lGL -lXext -lX11 -lXm -lXt -lm
15
16 #include <GL/GLwMDrawA.h>
17 ld ... -lGLw -lGL -lXext -lX11 -lXm -lXt -lm
18
19
20 DESCRIPTION
21 GLwDrawingArea and GLwMDrawingArea are widgets suitable for OpenGL
22 drawing. They provide a window with the appropriate visual and colormaps
23 needed for OpenGL, based on supplied parameters. GLwDrawingArea and
24 GLwMDrawingArea also provide callbacks for redraw, resize, input, and
25 initialization.
26
27 GLwDrawingArea is not a part of any widget set, but depends only on Xt.
28 GLwDrawingArea can be used with any widget set. GLwMDrawingArea is
29 identical to GLwDrawingArea except that it is a subclass of the Motif
30 widget class XmPrimitive and has resources and defaults suitable for use
31 with Motif. For example, GLwMDrawingArea provides the default Motif
32 background and foreground colors for resources, and deals better with
33 keyboard traversal. Although the GLwDrawingArea widget can be used in a
34 Motif program, it is recommended that GLwMDrawingArea be used instead.
35
36 Since both GLwDrawingArea and GLwMDrawingArea widgets behave almost
37 identically, the remainder of this manual page will refer only to
38 GLwDrawingArea, except when the behaviors differ. Unless explicitly
39 stated, all statements about GLwDrawingArea also apply to
40 GLwMDrawingArea.
41
42 Among the information provided when creating a GLwDrawingArea is
43 information necessary to determine the visual. This may be provided in
44 three ways, all of them through resources. A specific visualInfo
45 structure may be passed in. (This visualInfo must have been obtained
46 elsewhere; it is the application designer's responsibility to make sure
47 that it is compatible with the OpenGL rendering done by the application).
48 Alternatively, an attribute list may be provided. This attribute list is
49 formatted identically to that used for direct open GL programming.
50 Finally, each attribute can be specified as an individual resource. The
51 latter method is the simplest, and is the only method that works from
52 resource files.
53
54 In addition to allocating the visual, the GLwDrawingArea will also
55 allocate the colormap unless one is provided by the application. (If one
56 is provided it is the application writer's responsibility to guarantee
57 compatibility between the colormap and the visual). If an application
58 creates multiple GLwDrawingAreas with the same visual, the same colormap
59 will be used. (However the colormap will not be shared among separate
60
61
62
63 Page 1
64
65
66
67
68
69
70 GLwDrawingArea(3X) GLwDrawingArea(3X)
71
72
73
74 applications).
75
76 Creating the widget does not actually create the window until it is
77 realized, and consequently, the application should not perform any OpenGL
78 operations to the window immediately after creation. Instead the
79 application must wait until after it has realized the window.
80 Alternatively, the ginit callback may be used to indicate when the window
81 has been created. Upon receiving this callback, the application can
82 perform all OpenGL initialization for the window, and can subsequently
83 perform other operations on it. The initialization is discussed in more
84 detail below.
85
86 Applications select which GLwDrawingArea they are accessing using either
87 glXMakeCurrent or the convenience function GLwDrawingAreaMakeCurrent
88 which uses a widget instead of a display and window. If there is only
89 one GLwDrawingArea this need only be called once, however if there is
90 more than one GLwDrawingArea it should be called at the start of each
91 callback. Callbacks in this case include not only callbacks provided by
92 the widget itself, but any other callback that leads to GL activity such
93 as a timeout or a workproc.
94
95 If an application is using double buffering, it may call
96 GLwDrawingAreaSwapBuffers instead of glXSwapBuffers. This allows the use
97 of the widget instead of the display and window.
98
99 GLwDrawingArea Classes
100 GLwDrawingArea inherits behavior and resources from the Core class.
101 The class pointer is GLwDrawingAreaWidgetClass.
102 The class name is GLwDrawingArea.
103
104 GLwMDrawingArea Classes
105 GLwMDrawingArea inherits behavior and resources from the XmPrimitive and
106 Core classes.
107 The class pointer is GLwMDrawingAreaWidgetClass.
108 The class name is GLwMDrawingArea.
109
110
111 New Resources
112 The following tables define a set of widget resources used by the
113 programmer to specify data. The programmer can also set the resource
114 values for the inherited classes to set attributes for this widget. To
115 reference a resource by name or by class in a .Xdefaults file, remove the
116 GLwN or GLwC prefix and use the remaining letters. There are two tables
117 included. The first table includes resources that correspond directly to
118 the attributes used by glXChooseVisual. As with glXChooseVisual, all
119 Boolean resources default to FALSE and all integer resources default to
120 0, except redSize, greenSize and blueSize which default to 1. These
121 resources can all be set only at creation time, and are used to determine
122 the visual. If either the GLwNattribList or GLwNvisualInfo resource is
123 set, these resources are ignored. The specific meaning of these
124 resources is discussed in the glXChooseVisual manual page and will not be
125 discussed here.
126
127
128
129 Page 2
130
131
132
133
134
135
136 GLwDrawingArea(3X) GLwDrawingArea(3X)
137
138
139
140 ___________________________________________________________________________
141 | Name | Class | Type | OpenGL attribute |
142 |___________________|____________________|_________|______________________|
143 | GLwNbufferSize | GLwCBufferSize | int | GLX_BUFFER_SIZE |
144 |___________________|____________________|_________|______________________|
145 | GLwNlevel | GLwCLevel | int | GLX_LEVEL |
146 |___________________|____________________|_________|______________________|
147 | GLwNrgba | GLwCRgba | Boolean| GLX_RGBA |
148 |___________________|____________________|_________|______________________|
149 | GLwNdoublebuffer | GLwCDoublebuffer | Boolean| GLX_DOUBLEBUFFER |
150 |___________________|____________________|_________|______________________|
151 | GLwNstereo | GLwCStereo | Boolean| GLX_STEREO |
152 |___________________|____________________|_________|______________________|
153 | GLwNauxBuffers | GLwCAuxBuffers | Boolean| GLX_AUX_BUFFERS |
154 |___________________|____________________|_________|______________________|
155 | GLwNredSize | GLwCColorSize | int | GLX_RED_SIZE |
156 |___________________|____________________|_________|______________________|
157 | GLwNgreenSize | GLwCColorSize | int | GLX_GREEN_SIZE |
158 |___________________|____________________|_________|______________________|
159 | GLwNblueSize | GLwCColorSize | int | GLX_BLUE_SIZE |
160 |___________________|____________________|_________|______________________|
161 | GLwNalphaSize | GLwCAlphaSize | int | GLX_ALPHA_SIZE |
162 |___________________|____________________|_________|______________________|
163 | GLwNdepthSize | GLwCDepthSize | int | GLX_DEPTH_SIZE |
164 |___________________|____________________|_________|______________________|
165 | GLwNstencilSize | GLwCStencilSize | int | GLX_STENCIL_SIZE |
166 |___________________|____________________|_________|______________________|
167 | GLwNaccumRedSize | GLwCAccumColorSize| int | GLX_ACCUM_RED_SIZE |
168 |___________________|____________________|_________|______________________|
169 | GLwNaccumGreenSize| GLwCAccumColorSize| int | GLX_ACCUM_GREEN_SIZE|
170 |___________________|____________________|_________|______________________|
171 | GLwNaccumBlueSize | GLwCAccumColorSize| int | GLX_ACCUM_BLUE_SIZE |
172 |___________________|____________________|_________|______________________|
173 | GLwNaccumAlphaSize| GLwCAccumAlphaSize| int | GLX_ACCUM_ALPHA_SIZE|
174 |___________________|____________________|_________|______________________|
175
176
177 The following table lists other resources of the GLwDrawingArea widget.
178 each of these will be described subsequently. The codes in the access
179 column indicate if the given resource can be set at creation time (C),
180 set by using XtSetValues (S), retrieved by using XtGetValues (G), or is
181 not applicable (N/A).
182
183
184
185
186
187
188
189
190
191
192
193
194
195 Page 3
196
197
198
199
200
201
202 GLwDrawingArea(3X) GLwDrawingArea(3X)
203
204
205
206 Name Class Type Def Acc
207 _____________________________________________________________________________
208 GLwNallocateBackground GLwCAllocateColors Boolean F CG
209 GLwNallocateOtherColors GLwCAllocateColors Boolean F CG
210 GLwNattribList GLwCAttribList int * NULL CG
211 GLwNexposeCallback GLwCCallback XtCallbackList NULL C
212 GLwNginitCallback GLwCCallback XtCallbackList NULL C
213 GLwNinputCallback GLwCCallback XtCallbackList NULL C
214 GLwNinstallBackground GLwCInstallBackground Boolean T CG
215 GLwNinstallColormap GLwCInstallColormap Boolean T CG
216 GLwNresizeCallback GLwCCallback XtCallbackList NULL C
217 GLwNvisualInfo GLwCVisualInfo XVisualInfo* NULL CG
218
219
220 GLwNallocateBackground
221 If TRUE, the background pixel and pixmap will be allocated if
222 appropriate using the newly calculated colormap and visual. If
223 FALSE, they will retain values calculated using the parent's
224 colormap and visual. Applications which wish to have X clear their
225 background for them will usually set this to TRUE. Applications
226 clearing their own background will often set this to FALSE, although
227 they may set this to TRUE if they query the background for their own
228 use. One reason to leave this resource FALSE is that if color index
229 mode is in use this avoid using up a pixel from the newly allocated
230 colormap. Also, on hardware that supports only one colormap, the
231 application may need to do more careful color allocation to avoid
232 flashing between the openGL colormap and the default X colormap.
233 (Note that because of the way Xt works, the background colors are
234 originally calculated using the default colormap; if this resource
235 is set they can be recalculated correctly. If a colormap was
236 explicitly supplied to the widget rather than being dynamically
237 calculated, these resources are always calculated using that
238 colormap.)
239
240 GLwNallocateOtherColors
241 This is similar to GLwNallocateBackground, but allocates other
242 colors normally allocated by widgets. Although the GLwDrawingArea
243 and GLwMDrawingArea widget do not make use of these colors the
244 application may choose to query them. For the non-Motif
245 GLwDrawingArea widget there are no other colors allocated, so this
246 resource is a no-op. For the Motif GLwMDrawingArea are widget, the
247 XmPrimitive resources XmNforeground, XmNhighlightColor, and
248 XmNhighlightPixmap are calculated.
249
250 GLwNattribList
251 Contains the list of attributes suitable for a call to
252 glXChooseVisual. If this resource is NULL, it is calculated based
253 on the attribute resources. If it is not NULL, the attribute
254 resources are ignored.
255
256
257
258
259
260
261 Page 4
262
263
264
265
266
267
268 GLwDrawingArea(3X) GLwDrawingArea(3X)
269
270
271
272 GLwNexposeCallback
273 Specifies the list of callbacks that is called when the widget
274 receives an exposure event. The callback reason is GLwCR_EXPOSE.
275 The callback structure also includes the exposure event. The
276 application will generally want to redraw the scene.
277
278 GLwNginitCallback
279 Specifies the list of callbacks that is called when the widget is
280 first realized. Since no OpenGL operations can be done before the
281 widget is realized, this callback can be used to perform any
282 appropriate OpenGL initialization such as creating a context. The
283 callback reason is GLwCR_GINIT.
284
285 GLwNinputCallback
286 Specifies the list of callbacks that is called when the widget
287 receives a keyboard or mouse event. By default, the input callback
288 is called on each key press and key release, on each mouse button
289 press and release, and whenever the mouse is moved while a button is
290 pressed. However this can be changed by providing a different
291 translation table. The callback structure also includes the input
292 event. The callback reason is GLwCR_INPUT.
293
294 The input callback is provided as a programming convenience, as it
295 provides a convenient way to catch all input events. However, a
296 more modular program can often be obtained by providing specific
297 actions and translations in the application rather than using a
298 single catch all callback. Use of explicit translations can also
299 provide for more customizability.
300
301 GLwNinstallBackground
302 If set to TRUE, the background is installed on the window. If set
303 to FALSE, the window has no background. This resource has no effect
304 unless GLwNallocateBackground is also TRUE.
305
306 GLwNinstallColormap
307 If set to TRUE, the widget will call XSetWMColormapWindows to tell
308 the window manager to install the colormap when the window's shell
309 has focus. If set to FALSE, this will not be called. For
310 applications with multiple GLwDrawingAreas sharing a single
311 colormap, it is most efficient to set this resource to TRUE for
312 exactly one GLwDrawingArea with each colormap. If an application
313 needs additional control over the order of colormaps, this resource
314 can be set to FALSE, with the application calling
315 XSetWMColormapWindows explicitly.
316
317 GLwNresizeCallback
318 Specifies the list of callbacks that is called when the
319 GLwDrawingArea is resized. The callback reason is GLwCR_RESIZE.
320
321 GLwNvisualInfo
322 Contains a pointer to the window's visual info structure. If NULL,
323 the visualInfo is calculated at widget creation time based on the
324
325
326
327 Page 5
328
329
330
331
332
333
334 GLwDrawingArea(3X) GLwDrawingArea(3X)
335
336
337
338 GLwNattributeList resource (which is itself calculated from the
339 various resources). If GLwNvisualInfo is not NULL the
340 GLwNattributList and the attribute resources are ignored.
341
342
343 Inherited Resources
344 Both GLwDrawingArea and GLwMDrawingArea inherit behavior and
345 resources from the core superclass. Other than the behavior of the
346 colormap and background resources described previously, all defaults are
347 the same as for core.
348
349 In addition, the Motif version GLwMDrawingArea also inherits from
350 XmPrimitive. The behavior of the color resources has been described
351 previously. The TraversalOn resource is disabled for this widget, but if
352 keyboard input is required it should be enabled. (Also, the application
353 should call XmProcessTraversal(widget, XmTRAVERSE_CURRENT) whenever mouse
354 button 1 is clicked in the widget. This is similar to the requirements
355 of the Motif Drawing area.) Because Motif gets confused by having
356 multiple visuals in one top level shell, XmNhighlightOnEnter has been
357 disabled, and XmNhighlightThickness has been set to 0.
358
359 Callback Information
360 A pointer to the following structure is passed to each callback:
361
362 typedef struct
363 {
364 int reason;
365 XEvent * event;
366 Dimensionwidth, height;
367 } GLwDrawingAreaCallbackStruct;
368
369
370 reason Indicates why the callback was invoked. Appropriate values are
371 stated in the above resource descriptions. For Motif programmers,
372 the values GLwCR_EXPOSE, GLwCR_RESIZE, and GLwCR_INPUT are equal
373 to XmCR_EXPOSE, XmCR_RESIZE, and XmCR_INPUT respectively.
374 GLwCR_GINIT does not have a Motif equivalent.
375
376 event Points to the XEvent that triggered the callback. This is NULL
377 for GLwNginitCallback and GLwNresizeCallback.
378
379 width and height
380 Are set to the width and height of the window.
381
382
383
384
385
386
387
388
389
390
391
392
393 Page 6
394
395
396
397
398
399
400 GLwDrawingArea(3X) GLwDrawingArea(3X)
401
402
403
404 Translations
405 GLwDrawingArea has the translations listed below.
406
407 <KeyDown>: glwInput()
408 <KeyUp>: glwInput()
409 <BtnDown>: glwInput()
410 <BtnUp>: glwInput()
411 <BtnMotion>: glwInput()
412
413 GLwMDrawingArea has the following additional translation:
414
415 <Key>osfHelp: PrimitiveHelp()
416
417 An application wishing to catch other events than these defaults can do
418 so by installing a different translation table.
419
420
421
422 Action Routines
423 The GLwDrawingArea has the following action routine:
424
425 glwInput():
426 Called whenever one of the above translations specifies that input
427 has occurred. Its sole purpose is to call the input callback.
428
429
430 INITIALIZATION
431 When the widget is initially created (e.g. through XtCreateWidget(3X))
432 the associated window is not actually created. Instead, window creation
433 is delayed until the widget is realized. However, glXchooseVisual is
434 called immediately, so information based on its results is available.
435
436 Between the time the widget is created and it is realized, the following
437 apply:
438
439 o No OpenGL operations can be done to the window
440
441 o No resize callbacks are generated.
442
443 o The normal window is available (XtWindow returns NULL).
444
445 o GLwDrawingAreaMakeCurrent (and glXMakeCurrent) should not be called.
446
447 When the widget is realized, the following actions take place:
448
449 o The window is created.
450
451 o The ginit callback is called. The user may use this callback to
452 perform any needed OpenGL initialization to the window.
453
454
455
456
457
458
459 Page 7
460
461
462
463
464
465
466 GLwDrawingArea(3X) GLwDrawingArea(3X)
467
468
469
470 NOTES
471 When using the input callback to receive keyboard input, the keycode in
472 the event must be converted to a KeySym. Use XLookupKeysym(3X) or
473 XLookupString(3X) to do the conversion. Keyboard input can also be dealt
474 using translations, in which case no such conversion is required.
475
476 Motif programmers should keep in mind that OSF uses virtual bindings and
477 replaces some of the key bindings. As a common example, if the ESC key
478 is to be used to exit the program (as it often is in GL programs), the
479 translation should specify <key>osfCancel instead of <key>Escape.
480
481 Motif programmers may also create a GLwMDrawingArea widget with the Motif
482 style GLwCreateMDrawingArea.
483
484
485 EXAMPLE
486 Here are some code fragments that create a GLwDrawingArea widget, and
487 manage the appropriate callbacks.
488
489
490 #include <X11/GLW/GLwDrawingArea.h>
491 static GLXContext glx_context; /* assume only one context */
492 . . .
493
494 main()
495 {
496 Arg args[10];
497 int n;
498
499 Widget parent;/* The parent of the gl widget */
500 Widget glw;/* The GLwDrawingArea widget */
501 . . .
502
503 /* Create the widget using RGB mode. This can also be set
504 * in an X Defaults file
505 */
506 n = 0;
507 XtSetArg(args[n], GLwNrgba, TRUE); n++;
508 glw = XtCreateManagedWidget("glw", GLwDrawingAreaWidgetClass,
509 parent, args, n);
510 XtAddCallback(glw, GLwNexposeCallback, exposeCB, 0);
511 XtAddCallback(glw, GLwNresizeCallback, resizeCB, 0);
512 XtAddCallback(glw, GLwNginitCallback, ginitCB, 0);
513 /* Also add input callback if needed */
514 . . .
515 }
516
517 static void
518 exposeCB(Widget w, XtPointer client_data,
519 (GLwDrawingAreaCallbackStruct *)call_data)
520 {
521 GLwDrawingAreaMakeCurrent (w, glx_context);
522
523
524
525 Page 8
526
527
528
529
530
531
532 GLwDrawingArea(3X) GLwDrawingArea(3X)
533
534
535
536 /* redraw the display */
537 }
538
539 static void
540 resizeCB(Widget w, XtPointer client_data,
541 (GLwDrawingAreaCallbackStruct *)call_data)
542 {
543 GLwDrawingAreaMakeCurrent (w, glx_context);
544 /* perform any resize actions */
545 }
546
547 static void
548 ginitCB(Widget w, XtPointer client_data,
549 (GLwDrawingAreaCallbackStruct *)call_data)
550 {
551 Arg args[1];
552 XVisualInfo *vi;
553
554 XtSetArg(args[0], GLwNvisualInfo, &vi);
555 XtGetValues(w, args, 1);
556
557 /* create a visual context */
558 glx_context = glXCreateContext(XtDisplay(w), vi, 0, GL_FALSE);
559 GLwDrawingAreaMakeCurrent (w, glx_context);
560 /* Perform any necessary graphics initialization.*/
561 }
562
563
564 The Motif program need only differ by including GLwMDrawingArea.h instead
565 of GLwDrawingArea.h and by creating a widget of type
566 GLwMDrawingAreaWidgetClass instead of GLwDrawingAreaWidgetClass. As an
567 alternative, the Motif program could use GLwCreateMDraw(3X) instead.
568
569
570 WARNINGS
571 If a GLwDrawingArea widget is created as a child of an already realized
572 widget, the GLwDrawingArea widget will be created immediately, without
573 giving the user an opportunity to add the ginit callback. In such a
574 case, initialization should be done immediately after creating the widget
575 rather than by using the callback.
576
577 If the non-Motif GLwDrawingArea widget is used in a Motif program and
578 keyboard traversal is attempted, the behavior is undefined if the user
579 traverses into the GLwDrawingArea widget.
580
581 SEE ALSO
582 glXChooseVisual, GLwDrawingAreaMakeCurrent, glXMakeCurrent,
583 GLwDrawingAreaSwapBuffers GLwCreateMDraw, Core(3X), XmPrimitive(3X),
584 VirtualBindings(3X), Gflush(3G), XSetWMColormapWindows(3X11) and the
585 OpenGL spec.
586
587
588
589
590
591 Page 9
592
593
594
595