1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
'\" t
.TH QGLFormat 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QGLFormat \- The display format of an OpenGL rendering context
.SH SYNOPSIS
\fC#include <ntqgl.h>\fR
.PP
Inherits QGL.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQGLFormat\fR ()"
.br
.ti -1c
.BI "\fBQGLFormat\fR ( int options, int plane = 0 )"
.br
.ti -1c
.BI "bool \fBdoubleBuffer\fR () const"
.br
.ti -1c
.BI "void \fBsetDoubleBuffer\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBdepth\fR () const"
.br
.ti -1c
.BI "void \fBsetDepth\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBrgba\fR () const"
.br
.ti -1c
.BI "void \fBsetRgba\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBalpha\fR () const"
.br
.ti -1c
.BI "void \fBsetAlpha\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBaccum\fR () const"
.br
.ti -1c
.BI "void \fBsetAccum\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBstencil\fR () const"
.br
.ti -1c
.BI "void \fBsetStencil\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBstereo\fR () const"
.br
.ti -1c
.BI "void \fBsetStereo\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBdirectRendering\fR () const"
.br
.ti -1c
.BI "void \fBsetDirectRendering\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBhasOverlay\fR () const"
.br
.ti -1c
.BI "void \fBsetOverlay\fR ( bool enable )"
.br
.ti -1c
.BI "int \fBplane\fR () const"
.br
.ti -1c
.BI "void \fBsetPlane\fR ( int plane )"
.br
.ti -1c
.BI "void \fBsetOption\fR ( FormatOption opt )"
.br
.ti -1c
.BI "bool \fBtestOption\fR ( FormatOption opt ) const"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "QGLFormat \fBdefaultFormat\fR ()"
.br
.ti -1c
.BI "void \fBsetDefaultFormat\fR ( const QGLFormat & f )"
.br
.ti -1c
.BI "QGLFormat \fBdefaultOverlayFormat\fR ()"
.br
.ti -1c
.BI "void \fBsetDefaultOverlayFormat\fR ( const QGLFormat & f )"
.br
.ti -1c
.BI "bool \fBhasOpenGL\fR ()"
.br
.ti -1c
.BI "bool \fBhasOpenGLOverlays\fR ()"
.br
.in -1c
.SH DESCRIPTION
The QGLFormat class specifies the display format of an OpenGL rendering context.
.PP
A display format has several characteristics:
.TP
Double or single buffering.
.TP
Depth buffer.
.TP
RGBA or color index mode.
.TP
Alpha channel.
.TP
Accumulation buffer.
.TP
Stencil buffer.
.TP
Stereo buffers.
.TP
Direct rendering.
.TP
Presence of an overlay.
.TP
The plane of an overlay format.
.PP
You create and tell a QGLFormat object what rendering options you want from an OpenGL<sup>*</sup> rendering context.
.PP
OpenGL drivers or accelerated hardware may or may not support advanced features such as alpha channel or stereographic viewing. If you request some features that the driver/hardware does not provide when you create a QGLWidget, you will get a rendering context with the nearest subset of features.
.PP
There are different ways to define the display characteristics of a rendering context. One is to create a QGLFormat and make it the default for the entire application:
.PP
.nf
.br
QGLFormat f;
.br
f.setAlpha( TRUE );
.br
f.setStereo( TRUE );
.br
QGLFormat::setDefaultFormat( f );
.br
.fi
.PP
Or you can specify the desired format when creating an object of your QGLWidget subclass:
.PP
.nf
.br
QGLFormat f;
.br
f.setDoubleBuffer( FALSE ); // single buffer
.br
f.setDirectRendering( FALSE ); // software rendering
.br
MyGLWidget* myWidget = new MyGLWidget( f, ... );
.br
.fi
.PP
After the widget has been created, you can find out which of the requested features the system was able to provide:
.PP
.nf
.br
QGLFormat f;
.br
f.setOverlay( TRUE );
.br
f.setStereo( TRUE );
.br
MyGLWidget* myWidget = new MyGLWidget( f, ... );
.br
if ( !w->format().stereo() ) {
.br
// ok, goggles off
.br
if ( !w->format().hasOverlay() ) {
.br
tqFatal( "Cool hardware required" );
.br
}
.br
}
.br
.fi
.PP
<sup>*</sup> OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.
.PP
See also QGLContext, QGLWidget, Graphics Classes, and Image Processing Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QGLFormat::QGLFormat ()"
Constructs a QGLFormat object with the factory default settings:
.TP
Double buffer: Enabled.
.TP
Depth buffer: Enabled.
.TP
RGBA: Enabled (i.e., color index disabled).
.TP
Alpha channel: Disabled.
.TP
Accumulator buffer: Disabled.
.TP
Stencil buffer: Disabled.
.TP
Stereo: Disabled.
.TP
Direct rendering: Enabled.
.TP
Overlay: Disabled.
.TP
Plane: 0 (i.e., normal plane).
.SH "QGLFormat::QGLFormat ( int options, int plane = 0 )"
Creates a QGLFormat object that is a copy of the current application default format.
.PP
If \fIoptions\fR is not 0, this copy is modified by these format options. The \fIoptions\fR parameter should be FormatOption values OR'ed together.
.PP
This constructor makes it easy to specify a certain desired format in classes derived from QGLWidget, for example:
.PP
.nf
.br
// The rendering in MyGLWidget depends on using
.br
// stencil buffer and alpha channel
.br
MyGLWidget::MyGLWidget( QWidget* parent, const char* name )
.br
: QGLWidget( QGLFormat( StencilBuffer | AlphaChannel ), parent, name )
.br
{
.br
if ( !format().stencil() )
.br
tqWarning( "Could not get stencil buffer; results will be suboptimal" );
.br
if ( !format().alphaChannel() )
.br
tqWarning( "Could not get alpha channel; results will be suboptimal" );
.br
...
.br
}
.br
.fi
.PP
Note that there are FormatOption values to turn format settings both on and off, e.g. DepthBuffer and NoDepthBuffer, DirectRendering and IndirectRendering, etc.
.PP
The \fIplane\fR parameter defaults to 0 and is the plane which this format should be associated with. Not all OpenGL implmentations supports overlay/underlay rendering planes.
.PP
See also defaultFormat() and setOption().
.SH "bool QGLFormat::accum () const"
Returns TRUE if the accumulation buffer is enabled; otherwise returns FALSE. The accumulation buffer is disabled by default.
.PP
See also setAccum().
.SH "bool QGLFormat::alpha () const"
Returns TRUE if the alpha channel of the framebuffer is enabled; otherwise returns FALSE. The alpha channel is disabled by default.
.PP
See also setAlpha().
.SH "QGLFormat QGLFormat::defaultFormat ()\fC [static]\fR"
Returns the default QGLFormat for the application. All QGLWidgets that are created use this format unless another format is specified, e.g. when they are constructed.
.PP
If no special default format has been set using setDefaultFormat(), the default format is the same as that created with QGLFormat().
.PP
See also setDefaultFormat().
.SH "QGLFormat QGLFormat::defaultOverlayFormat ()\fC [static]\fR"
Returns the default QGLFormat for overlay contexts.
.PP
The factory default overlay format is:
.TP
Double buffer: Disabled.
.TP
Depth buffer: Disabled.
.TP
RGBA: Disabled (i.e., color index enabled).
.TP
Alpha channel: Disabled.
.TP
Accumulator buffer: Disabled.
.TP
Stencil buffer: Disabled.
.TP
Stereo: Disabled.
.TP
Direct rendering: Enabled.
.TP
Overlay: Disabled.
.TP
Plane: 1 (i.e., first overlay plane).
.PP
See also setDefaultFormat().
.SH "bool QGLFormat::depth () const"
Returns TRUE if the depth buffer is enabled; otherwise returns FALSE. The depth buffer is enabled by default.
.PP
See also setDepth().
.SH "bool QGLFormat::directRendering () const"
Returns TRUE if direct rendering is enabled; otherwise returns FALSE.
.PP
Direct rendering is enabled by default.
.PP
See also setDirectRendering().
.SH "bool QGLFormat::doubleBuffer () const"
Returns TRUE if double buffering is enabled; otherwise returns FALSE. Double buffering is enabled by default.
.PP
See also setDoubleBuffer().
.SH "bool QGLFormat::hasOpenGL ()\fC [static]\fR"
Returns TRUE if the window system has any OpenGL support; otherwise returns FALSE.
.PP
\fBWarning:\fR This function must not be called until the QApplication object has been created.
.SH "bool QGLFormat::hasOpenGLOverlays ()\fC [static]\fR"
Returns TRUE if the window system supports OpenGL overlays; otherwise returns FALSE.
.PP
\fBWarning:\fR This function must not be called until the QApplication object has been created.
.SH "bool QGLFormat::hasOverlay () const"
Returns TRUE if overlay plane is enabled; otherwise returns FALSE.
.PP
Overlay is disabled by default.
.PP
See also setOverlay().
.SH "int QGLFormat::plane () const"
Returns the plane of this format. The default for normal formats is 0, which means the normal plane. The default for overlay formats is 1, which is the first overlay plane.
.PP
See also setPlane().
.SH "bool QGLFormat::rgba () const"
Returns TRUE if RGBA color mode is set. Returns FALSE if color index mode is set. The default color mode is RGBA.
.PP
See also setRgba().
.SH "void QGLFormat::setAccum ( bool enable )"
If \fIenable\fR is TRUE enables the accumulation buffer; otherwise disables the accumulation buffer.
.PP
The accumulation buffer is disabled by default.
.PP
The accumulation buffer is used to create blur effects and multiple exposures.
.PP
See also accum().
.SH "void QGLFormat::setAlpha ( bool enable )"
If \fIenable\fR is TRUE enables the alpha channel; otherwise disables the alpha channel.
.PP
The alpha buffer is disabled by default.
.PP
The alpha channel is typically used for implementing transparency or translucency. The A in RGBA specifies the transparency of a pixel.
.PP
See also alpha().
.SH "void QGLFormat::setDefaultFormat ( const QGLFormat & f )\fC [static]\fR"
Sets a new default QGLFormat for the application to \fIf\fR. For example, to set single buffering as the default instead of double buffering, your main() might contain code like this:
.PP
.nf
.br
QApplication a(argc, argv);
.br
QGLFormat f;
.br
f.setDoubleBuffer( FALSE );
.br
QGLFormat::setDefaultFormat( f );
.br
.fi
.PP
See also defaultFormat().
.SH "void QGLFormat::setDefaultOverlayFormat ( const QGLFormat & f )\fC [static]\fR"
Sets a new default QGLFormat for overlay contexts to \fIf\fR. This format is used whenever a QGLWidget is created with a format that hasOverlay() enabled.
.PP
For example, to get a double buffered overlay context (if available), use code like this:
.PP
.nf
.br
QGLFormat f = QGLFormat::defaultOverlayFormat();
.br
f.setDoubleBuffer( TRUE );
.br
QGLFormat::setDefaultOverlayFormat( f );
.br
.fi
.PP
As usual, you can find out after widget creation whether the underlying OpenGL system was able to provide the requested specification:
.PP
.nf
.br
// ...continued from above
.br
MyGLWidget* myWidget = new MyGLWidget( QGLFormat( QGL::HasOverlay ), ... );
.br
if ( myWidget->format().hasOverlay() ) {
.br
// Yes, we got an overlay, let's check _its_ format:
.br
QGLContext* olContext = myWidget->overlayContext();
.br
if ( olContext->format().doubleBuffer() )
.br
; // yes, we got a double buffered overlay
.br
else
.br
; // no, only single buffered overlays are available
.br
}
.br
.fi
.PP
See also defaultOverlayFormat().
.SH "void QGLFormat::setDepth ( bool enable )"
If \fIenable\fR is TRUE enables the depth buffer; otherwise disables the depth buffer.
.PP
The depth buffer is enabled by default.
.PP
The purpose of a depth buffer (or Z-buffering) is to remove hidden surfaces. Pixels are assigned Z values based on the distance to the viewer. A pixel with a high Z value is closer to the viewer than a pixel with a low Z value. This information is used to decide whether to draw a pixel or not.
.PP
See also depth().
.SH "void QGLFormat::setDirectRendering ( bool enable )"
If \fIenable\fR is TRUE enables direct rendering; otherwise disables direct rendering.
.PP
Direct rendering is enabled by default.
.PP
Enabling this option will make OpenGL bypass the underlying window system and render directly from hardware to the screen, if this is supported by the system.
.PP
See also directRendering().
.SH "void QGLFormat::setDoubleBuffer ( bool enable )"
If \fIenable\fR is TRUE sets double buffering; otherwise sets single buffering.
.PP
Double buffering is enabled by default.
.PP
Double buffering is a technique where graphics are rendered on an off-screen buffer and not directly to the screen. When the drawing has been completed, the program calls a swapBuffers() function to exchange the screen contents with the buffer. The result is flicker-free drawing and often better performance.
.PP
See also doubleBuffer(), QGLContext::swapBuffers(), and QGLWidget::swapBuffers().
.SH "void QGLFormat::setOption ( FormatOption opt )"
Sets the format option to \fIopt\fR.
.PP
See also testOption().
.SH "void QGLFormat::setOverlay ( bool enable )"
If \fIenable\fR is TRUE enables an overlay plane; otherwise disables the overlay plane.
.PP
Enabling the overlay plane will cause QGLWidget to create an additional context in an overlay plane. See the QGLWidget documentation for further information.
.PP
See also hasOverlay().
.SH "void QGLFormat::setPlane ( int plane )"
Sets the requested plane to \fIplane\fR. 0 is the normal plane, 1 is the first overlay plane, 2 is the second overlay plane, etc.; -1, -2, etc. are underlay planes.
.PP
Note that in contrast to other format specifications, the plane specifications will be matched exactly. This means that if you specify a plane that the underlying OpenGL system cannot provide, an invalid QGLWidget will be created.
.PP
See also plane().
.SH "void QGLFormat::setRgba ( bool enable )"
If \fIenable\fR is TRUE sets RGBA mode. If \fIenable\fR is FALSE sets color index mode.
.PP
The default color mode is RGBA.
.PP
RGBA is the preferred mode for most OpenGL applications. In RGBA color mode you specify colors as red + green + blue + alpha quadruplets.
.PP
In color index mode you specify an index into a color lookup table.
.PP
See also rgba().
.SH "void QGLFormat::setStencil ( bool enable )"
If \fIenable\fR is TRUE enables the stencil buffer; otherwise disables the stencil buffer.
.PP
The stencil buffer is disabled by default.
.PP
The stencil buffer masks certain parts of the drawing area so that masked parts are not drawn on.
.PP
See also stencil().
.SH "void QGLFormat::setStereo ( bool enable )"
If \fIenable\fR is TRUE enables stereo buffering; otherwise disables stereo buffering.
.PP
Stereo buffering is disabled by default.
.PP
Stereo buffering provides extra color buffers to generate left-eye and right-eye images.
.PP
See also stereo().
.SH "bool QGLFormat::stencil () const"
Returns TRUE if the stencil buffer is enabled; otherwise returns FALSE. The stencil buffer is disabled by default.
.PP
See also setStencil().
.SH "bool QGLFormat::stereo () const"
Returns TRUE if stereo buffering is enabled; otherwise returns FALSE. Stereo buffering is disabled by default.
.PP
See also setStereo().
.SH "bool QGLFormat::testOption ( FormatOption opt ) const"
Returns TRUE if format option \fIopt\fR is set; otherwise returns FALSE.
.PP
See also setOption().
.SH "SEE ALSO"
.BR http://doc.trolltech.com/qglformat.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqglformat.3qt) and the Qt
version (3.3.8).
|