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
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/opengl/qgl.cpp:1126 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQGLWidget Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQGLWidget Class Reference<br><small>[<a href="opengl.html">OpenGL module</a>]</small></h1>
<p>The TQGLWidget class is a widget for rendering OpenGL graphics.
<a href="#details">More...</a>
<p><tt>#include <<a href="qgl-h.html">ntqgl.h</a>></tt>
<p>Inherits <a href="ntqwidget.html">TQWidget</a> and <a href="ntqgl.html">TQGL</a>.
<p><a href="qglwidget-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQGLWidget"><b>TQGLWidget</b></a> ( TQWidget * parent = 0, const char * name = 0, const TQGLWidget * shareWidget = 0, WFlags f = 0 )</li>
<li class=fn><a href="#TQGLWidget-2"><b>TQGLWidget</b></a> ( TQGLContext * context, TQWidget * parent, const char * name = 0, const TQGLWidget * shareWidget = 0, WFlags f = 0 )</li>
<li class=fn><a href="#TQGLWidget-3"><b>TQGLWidget</b></a> ( const TQGLFormat & format, TQWidget * parent = 0, const char * name = 0, const TQGLWidget * shareWidget = 0, WFlags f = 0 )</li>
<li class=fn><a href="#~TQGLWidget"><b>~TQGLWidget</b></a> ()</li>
<li class=fn>void <a href="#qglColor"><b>qglColor</b></a> ( const TQColor & c ) const</li>
<li class=fn>void <a href="#qglClearColor"><b>qglClearColor</b></a> ( const TQColor & c ) const</li>
<li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li>
<li class=fn>bool <a href="#isSharing"><b>isSharing</b></a> () const</li>
<li class=fn>virtual void <a href="#makeCurrent"><b>makeCurrent</b></a> ()</li>
<li class=fn>void <a href="#doneCurrent"><b>doneCurrent</b></a> ()</li>
<li class=fn>bool <a href="#doubleBuffer"><b>doubleBuffer</b></a> () const</li>
<li class=fn>virtual void <a href="#swapBuffers"><b>swapBuffers</b></a> ()</li>
<li class=fn>TQGLFormat <a href="#format"><b>format</b></a> () const</li>
<li class=fn>const TQGLContext * <a href="#context"><b>context</b></a> () const</li>
<li class=fn>virtual TQPixmap <a href="#renderPixmap"><b>renderPixmap</b></a> ( int w = 0, int h = 0, bool useContext = FALSE )</li>
<li class=fn>virtual TQImage <a href="#grabFrameBuffer"><b>grabFrameBuffer</b></a> ( bool withAlpha = FALSE )</li>
<li class=fn>virtual void <a href="#makeOverlayCurrent"><b>makeOverlayCurrent</b></a> ()</li>
<li class=fn>const TQGLContext * <a href="#overlayContext"><b>overlayContext</b></a> () const</li>
<li class=fn>const TQGLColormap & <a href="#colormap"><b>colormap</b></a> () const</li>
<li class=fn>void <a href="#setColormap"><b>setColormap</b></a> ( const TQGLColormap & cmap )</li>
<li class=fn>void <a href="#renderText"><b>renderText</b></a> ( int x, int y, const TQString & str, const TQFont & fnt = TQFont ( ), int listBase = 2000 )</li>
<li class=fn>void <a href="#renderText-2"><b>renderText</b></a> ( double x, double y, double z, const TQString & str, const TQFont & fnt = TQFont ( ), int listBase = 2000 )</li>
</ul>
<h2>Public Slots</h2>
<ul>
<li class=fn>virtual void <a href="#updateGL"><b>updateGL</b></a> ()</li>
<li class=fn>virtual void <a href="#updateOverlayGL"><b>updateOverlayGL</b></a> ()</li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li class=fn>TQImage <a href="#convertToGLFormat"><b>convertToGLFormat</b></a> ( const TQImage & img )</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#initializeGL"><b>initializeGL</b></a> ()</li>
<li class=fn>virtual void <a href="#resizeGL"><b>resizeGL</b></a> ( int width, int height )</li>
<li class=fn>virtual void <a href="#paintGL"><b>paintGL</b></a> ()</li>
<li class=fn>virtual void <a href="#initializeOverlayGL"><b>initializeOverlayGL</b></a> ()</li>
<li class=fn>virtual void <a href="#resizeOverlayGL"><b>resizeOverlayGL</b></a> ( int width, int height )</li>
<li class=fn>virtual void <a href="#paintOverlayGL"><b>paintOverlayGL</b></a> ()</li>
<li class=fn>void <a href="#setAutoBufferSwap"><b>setAutoBufferSwap</b></a> ( bool on )</li>
<li class=fn>bool <a href="#autoBufferSwap"><b>autoBufferSwap</b></a> () const</li>
<li class=fn>virtual void <a href="#paintEvent"><b>paintEvent</b></a> ( TQPaintEvent * )</li>
<li class=fn>virtual void <a href="#resizeEvent"><b>resizeEvent</b></a> ( TQResizeEvent * )</li>
<li class=fn>virtual void <a href="#glInit"><b>glInit</b></a> ()</li>
<li class=fn>virtual void <a href="#glDraw"><b>glDraw</b></a> ()</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQGLWidget class is a widget for rendering OpenGL graphics.
<p>
<p> TQGLWidget provides functionality for displaying OpenGL<sup>*</sup>
graphics integrated into a TQt application. It is very simple to
use. You inherit from it and use the subclass like any other
<a href="ntqwidget.html">TQWidget</a>, except that instead of drawing the widget's contents
using <a href="ntqpainter.html">TQPainter</a> etc. you use the standard OpenGL rendering
commands.
<p> TQGLWidget provides three convenient virtual functions that you can
reimplement in your subclass to perform the typical OpenGL tasks:
<p> <ul>
<li> <a href="#paintGL">paintGL</a>() - Renders the OpenGL scene. Gets called whenever the widget
needs to be updated.
<li> <a href="#resizeGL">resizeGL</a>() - Sets up the OpenGL viewport, projection, etc. Gets
called whenever the the widget has been resized (and also when it
is shown for the first time because all newly created widgets get a
resize event automatically).
<li> <a href="#initializeGL">initializeGL</a>() - Sets up the OpenGL rendering context, defines display
lists, etc. Gets called once before the first time resizeGL() or
paintGL() is called.
</ul>
<p> Here is a rough outline of how a TQGLWidget subclass might look:
<p> <pre>
class MyGLDrawer : public TQGLWidget
{
TQ_OBJECT // must include this if you use TQt signals/slots
public:
MyGLDrawer( <a href="ntqwidget.html">TQWidget</a> *parent, const char *name )
: TQGLWidget(parent, name) {}
protected:
void initializeGL()
{
// Set up the rendering context, define display lists etc.:
...
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glEnable(GL_DEPTH_TEST);
...
}
void resizeGL( int w, int h )
{
// setup viewport, projection etc.:
glViewport( 0, 0, (GLint)w, (GLint)h );
...
glFrustum( ... );
...
}
void paintGL()
{
// draw the scene:
...
glRotatef( ... );
glMaterialfv( ... );
glBegin( GL_QUADS );
glVertex3f( ... );
glVertex3f( ... );
...
glEnd();
...
}
};
</pre>
<p> If you need to trigger a repaint from places other than <a href="#paintGL">paintGL</a>()
(a typical example is when using <a href="ntqtimer.html">timers</a> to
animate scenes), you should call the widget's <a href="#updateGL">updateGL</a>() function.
<p> Your widget's OpenGL rendering context is made current when
paintGL(), <a href="#resizeGL">resizeGL</a>(), or <a href="#initializeGL">initializeGL</a>() is called. If you need to
call the standard OpenGL API functions from other places (e.g. in
your widget's constructor or in your own paint functions), you
must call <a href="#makeCurrent">makeCurrent</a>() first.
<p> TQGLWidget provides functions for requesting a new display <a href="qglformat.html">format</a> and you can also create widgets with
customized rendering <a href="qglcontext.html">contexts</a>.
<p> You can also share OpenGL display lists between TQGLWidgets (see
the documentation of the TQGLWidget constructors for details).
<p> <h3> Overlays
</h3>
<a name="1"></a><p> The TQGLWidget creates a GL overlay context in addition to the
normal context if overlays are supported by the underlying system.
<p> If you want to use overlays, you specify it in the <a href="qglformat.html">format</a>. (Note: Overlay must be requested in the format
passed to the TQGLWidget constructor.) Your GL widget should also
implement some or all of these virtual methods:
<p> <ul>
<li> <a href="#paintOverlayGL">paintOverlayGL</a>()
<li> <a href="#resizeOverlayGL">resizeOverlayGL</a>()
<li> <a href="#initializeOverlayGL">initializeOverlayGL</a>()
</ul>
<p> These methods work in the same way as the normal <a href="#paintGL">paintGL</a>() etc.
functions, except that they will be called when the overlay
context is made current. You can explicitly make the overlay
context current by using <a href="#makeOverlayCurrent">makeOverlayCurrent</a>(), and you can access
the overlay context directly (e.g. to ask for its transparent
color) by calling <a href="#overlayContext">overlayContext</a>().
<p> On X servers in which the default visual is in an overlay plane,
non-GL TQt windows can also be used for overlays. See the
examples/opengl/overlay_x11 example program for details.
<p> <sup>*</sup> OpenGL is a trademark of Silicon Graphics, Inc. in the
United States and other countries.
<p>See also <a href="graphics.html">Graphics Classes</a> and <a href="images.html">Image Processing Classes</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQGLWidget"></a>TQGLWidget::TQGLWidget ( <a href="ntqwidget.html">TQWidget</a> * parent = 0, const char * name = 0, const <a href="qglwidget.html">TQGLWidget</a> * shareWidget = 0, WFlags f = 0 )
</h3>
Constructs an OpenGL widget with a <em>parent</em> widget and a <em>name</em>.
<p> The <a href="qglformat.html#defaultFormat">default format</a> is
used. The widget will be <a href="#isValid">invalid</a> if the
system has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.
<p> The <em>parent</em>, <em>name</em> and <a href="ntqt.html#WidgetFlags">widget flag</a>, <em>f</em>, arguments are passed
to the <a href="ntqwidget.html">TQWidget</a> constructor.
<p> If the <em>shareWidget</em> parameter points to a valid TQGLWidget, this
widget will share OpenGL display lists with <em>shareWidget</em>. If
this widget and <em>shareWidget</em> have different <a href="#format">formats</a>, display list sharing may fail. You can check
whether display list sharing succeeded by calling <a href="#isSharing">isSharing</a>().
<p> The initialization of OpenGL rendering state, etc. should be done
by overriding the <a href="#initializeGL">initializeGL</a>() function, rather than in the
constructor of your TQGLWidget subclass.
<p> <p>See also <a href="qglformat.html#defaultFormat">TQGLFormat::defaultFormat</a>().
<h3 class=fn><a name="TQGLWidget-2"></a>TQGLWidget::TQGLWidget ( <a href="qglcontext.html">TQGLContext</a> * context, <a href="ntqwidget.html">TQWidget</a> * parent, const char * name = 0, const <a href="qglwidget.html">TQGLWidget</a> * shareWidget = 0, WFlags f = 0 )
</h3>
Constructs an OpenGL widget with parent <em>parent</em>, called <em>name</em>.
<p> The <em>context</em> argument is a pointer to the <a href="qglcontext.html">TQGLContext</a> that
you wish to be bound to this widget. This allows you to pass in
your own TQGLContext sub-classes.
<p> The widget will be <a href="#isValid">invalid</a> if the system
has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.
<p> The <em>parent</em>, <em>name</em> and <a href="ntqt.html#WidgetFlags">widget flag</a>, <em>f</em>, arguments are passed
to the <a href="ntqwidget.html">TQWidget</a> constructor.
<p> If the <em>shareWidget</em> parameter points to a valid TQGLWidget, this
widget will share OpenGL display lists with <em>shareWidget</em>. If
this widget and <em>shareWidget</em> have different <a href="#format">formats</a>, display list sharing may fail. You can check
whether display list sharing succeeded by calling <a href="#isSharing">isSharing</a>().
<p> The initialization of OpenGL rendering state, etc. should be done
by overriding the <a href="#initializeGL">initializeGL</a>() function, rather than in the
constructor of your TQGLWidget subclass.
<p> <p>See also <a href="qglformat.html#defaultFormat">TQGLFormat::defaultFormat</a>() and <a href="#isValid">isValid</a>().
<h3 class=fn><a name="TQGLWidget-3"></a>TQGLWidget::TQGLWidget ( const <a href="qglformat.html">TQGLFormat</a> & format, <a href="ntqwidget.html">TQWidget</a> * parent = 0, const char * name = 0, const <a href="qglwidget.html">TQGLWidget</a> * shareWidget = 0, WFlags f = 0 )
</h3>
Constructs an OpenGL widget with parent <em>parent</em>, called <em>name</em>.
<p> The <em>format</em> argument specifies the desired <a href="qglformat.html">rendering options</a>. If the underlying OpenGL/Window system
cannot satisfy all the features requested in <em>format</em>, the
nearest subset of features will be used. After creation, the
<a href="#format">format</a>() method will return the actual format obtained.
<p> The widget will be <a href="#isValid">invalid</a> if the system
has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.
<p> The <em>parent</em>, <em>name</em> and <a href="ntqt.html#WidgetFlags">widget flag</a>, <em>f</em>, arguments are passed
to the <a href="ntqwidget.html">TQWidget</a> constructor.
<p> If the <em>shareWidget</em> parameter points to a valid TQGLWidget, this
widget will share OpenGL display lists with <em>shareWidget</em>. If
this widget and <em>shareWidget</em> have different <a href="#format">formats</a>, display list sharing may fail. You can check
whether display list sharing succeeded by calling <a href="#isSharing">isSharing</a>().
<p> The initialization of OpenGL rendering state, etc. should be done
by overriding the <a href="#initializeGL">initializeGL</a>() function, rather than in the
constructor of your TQGLWidget subclass.
<p> <p>See also <a href="qglformat.html#defaultFormat">TQGLFormat::defaultFormat</a>() and <a href="#isValid">isValid</a>().
<h3 class=fn><a name="~TQGLWidget"></a>TQGLWidget::~TQGLWidget ()
</h3>
Destroys the widget.
<h3 class=fn>bool <a name="autoBufferSwap"></a>TQGLWidget::autoBufferSwap () const<tt> [protected]</tt>
</h3>
<p> Returns TRUE if the widget is doing automatic GL buffer swapping;
otherwise returns FALSE.
<p> <p>See also <a href="#setAutoBufferSwap">setAutoBufferSwap</a>().
<h3 class=fn>const <a href="ntqglcolormap.html">TQGLColormap</a> & <a name="colormap"></a>TQGLWidget::colormap () const
</h3>
<p> Returns the colormap for this widget.
<p> Usually it is only top-level widgets that can have different
colormaps installed. Asking for the colormap of a child widget
will return the colormap for the child's top-level widget.
<p> If no colormap has been set for this widget, the TQColormap
returned will be empty.
<p> <p>See also <a href="#setColormap">setColormap</a>().
<h3 class=fn>const <a href="qglcontext.html">TQGLContext</a> * <a name="context"></a>TQGLWidget::context () const
</h3>
<p> Returns the context of this widget.
<p> It is possible that the context is not valid (see <a href="#isValid">isValid</a>()), for
example, if the underlying hardware does not support the format
attributes that were requested.
<h3 class=fn><a href="ntqimage.html">TQImage</a> <a name="convertToGLFormat"></a>TQGLWidget::convertToGLFormat ( const <a href="ntqimage.html">TQImage</a> & img )<tt> [static]</tt>
</h3>
Converts the image <em>img</em> into the unnamed format expected by
OpenGL functions such as glTexImage2D(). The returned image is not
usable as a <a href="ntqimage.html">TQImage</a>, but <a href="ntqimage.html#width">TQImage::width</a>(), <a href="ntqimage.html#height">TQImage::height</a>() and
<a href="ntqimage.html#bits">TQImage::bits</a>() may be used with OpenGL. The following few lines
are from the texture example. Most of the code is irrelevant, so
we just quote the relevant bits:
<p>
<pre> <a href="ntqimage.html">TQImage</a> tex1, tex2, buf;
if ( !buf.load( "gllogo.bmp" ) ) { // Load first image from file
</pre>
<p> We create <em>tex1</em> (and another variable) for OpenGL, and load a real
image into <em>buf</em>.
<p> <pre> <a name="x2118"></a> tex1 = TQGLWidget::<a href="#convertToGLFormat">convertToGLFormat</a>( buf ); // flipped 32bit RGBA
</pre>
<p> A few lines later, we convert <em>buf</em> into OpenGL format and store it
in <em>tex1</em>.
<p> <pre> <a name="x2121"></a><a name="x2120"></a> glTexImage2D( GL_TEXTURE_2D, 0, 3, tex1.<a href="ntqimage.html#width">width</a>(), tex1.<a href="ntqimage.html#height">height</a>(), 0,
<a name="x2119"></a> GL_RGBA, GL_UNSIGNED_BYTE, tex1.<a href="ntqimage.html#bits">bits</a>() );
</pre>
<p> Note the dimension restrictions for texture images as described in
the glTexImage2D() documentation. The width must be 2^m + 2*border
and the height 2^n + 2*border where m and n are integers and
border is either 0 or 1.
<p> Another function in the same example uses <em>tex1</em> with OpenGL.
<p>Example: <a href="qglwidget.html#x2118">opengl/texture/gltexobj.cpp</a>.
<h3 class=fn>void <a name="doneCurrent"></a>TQGLWidget::doneCurrent ()
</h3>
<p> Makes no GL context the current context. Normally, you do not need
to call this function; <a href="qglcontext.html">TQGLContext</a> calls it as necessary. However,
it may be useful in multithreaded environments.
<h3 class=fn>bool <a name="doubleBuffer"></a>TQGLWidget::doubleBuffer () const
</h3>
<p> Returns TRUE if the contained GL rendering context has double
buffering; otherwise returns FALSE.
<p> <p>See also <a href="qglformat.html#doubleBuffer">TQGLFormat::doubleBuffer</a>().
<h3 class=fn><a href="qglformat.html">TQGLFormat</a> <a name="format"></a>TQGLWidget::format () const
</h3>
<p> Returns the format of the contained GL rendering context.
<h3 class=fn>void <a name="glDraw"></a>TQGLWidget::glDraw ()<tt> [virtual protected]</tt>
</h3>
Executes the virtual function <a href="#paintGL">paintGL</a>().
<p> The widget's rendering context will become the current context and
<a href="#initializeGL">initializeGL</a>() will be called if it hasn't already been called.
<h3 class=fn>void <a name="glInit"></a>TQGLWidget::glInit ()<tt> [virtual protected]</tt>
</h3>
Initializes OpenGL for this widget's context. Calls the virtual
function <a href="#initializeGL">initializeGL</a>().
<h3 class=fn><a href="ntqimage.html">TQImage</a> <a name="grabFrameBuffer"></a>TQGLWidget::grabFrameBuffer ( bool withAlpha = FALSE )<tt> [virtual]</tt>
</h3>
Returns an image of the frame buffer. If <em>withAlpha</em> is TRUE the
alpha channel is included.
<p> Depending on your hardware, you can explicitly select which color
buffer to grab with a glReadBuffer() call before calling this
function.
<h3 class=fn>void <a name="initializeGL"></a>TQGLWidget::initializeGL ()<tt> [virtual protected]</tt>
</h3>
This virtual function is called once before the first call to
<a href="#paintGL">paintGL</a>() or <a href="#resizeGL">resizeGL</a>(), and then once whenever the widget has
been assigned a new <a href="qglcontext.html">TQGLContext</a>. Reimplement it in a subclass.
<p> This function should set up any required OpenGL context rendering
flags, defining display lists, etc.
<p> There is no need to call <a href="#makeCurrent">makeCurrent</a>() because this has already
been done when this function is called.
<h3 class=fn>void <a name="initializeOverlayGL"></a>TQGLWidget::initializeOverlayGL ()<tt> [virtual protected]</tt>
</h3>
This virtual function is used in the same manner as <a href="#initializeGL">initializeGL</a>()
except that it operates on the widget's overlay context instead of
the widget's main context. This means that <a href="#initializeOverlayGL">initializeOverlayGL</a>()
is called once before the first call to <a href="#paintOverlayGL">paintOverlayGL</a>() or
<a href="#resizeOverlayGL">resizeOverlayGL</a>(). Reimplement it in a subclass.
<p> This function should set up any required OpenGL context rendering
flags, defining display lists, etc. for the overlay context.
<p> There is no need to call <a href="#makeOverlayCurrent">makeOverlayCurrent</a>() because this has
already been done when this function is called.
<h3 class=fn>bool <a name="isSharing"></a>TQGLWidget::isSharing () const
</h3>
<p> Returns TRUE if display list sharing with another TQGLWidget was
requested in the constructor, and the GL system was able to
provide it; otherwise returns FALSE. The GL system may fail to
provide display list sharing if the two TQGLWidgets use different
formats.
<p> <p>See also <a href="#format">format</a>().
<h3 class=fn>bool <a name="isValid"></a>TQGLWidget::isValid () const
</h3>
<p> Returns TRUE if the widget has a valid GL rendering context;
otherwise returns FALSE. A widget will be invalid if the system
has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.
<h3 class=fn>void <a name="makeCurrent"></a>TQGLWidget::makeCurrent ()<tt> [virtual]</tt>
</h3>
<p> Makes this widget the current widget for OpenGL operations, i.e.
makes the widget's rendering context the current OpenGL rendering
context.
<h3 class=fn>void <a name="makeOverlayCurrent"></a>TQGLWidget::makeOverlayCurrent ()<tt> [virtual]</tt>
</h3>
<p> Makes the overlay context of this widget current. Use this if you
need to issue OpenGL commands to the overlay context outside of
<a href="#initializeOverlayGL">initializeOverlayGL</a>(), <a href="#resizeOverlayGL">resizeOverlayGL</a>(), and <a href="#paintOverlayGL">paintOverlayGL</a>().
<p> Does nothing if this widget has no overlay.
<p> <p>See also <a href="#makeCurrent">makeCurrent</a>().
<h3 class=fn>const <a href="qglcontext.html">TQGLContext</a> * <a name="overlayContext"></a>TQGLWidget::overlayContext () const
</h3>
<p> Returns the overlay context of this widget, or 0 if this widget
has no overlay.
<p> <p>See also <a href="#context">context</a>().
<h3 class=fn>void <a name="paintEvent"></a>TQGLWidget::paintEvent ( <a href="qpaintevent.html">TQPaintEvent</a> * )<tt> [virtual protected]</tt>
</h3>
Handles paint events. Will cause the virtual <a href="#paintGL">paintGL</a>() function to
be called.
<p> The widget's rendering context will become the current context and
<a href="#initializeGL">initializeGL</a>() will be called if it hasn't already been called.
<p>Reimplemented from <a href="ntqwidget.html#paintEvent">TQWidget</a>.
<h3 class=fn>void <a name="paintGL"></a>TQGLWidget::paintGL ()<tt> [virtual protected]</tt>
</h3>
This virtual function is called whenever the widget needs to be
painted. Reimplement it in a subclass.
<p> There is no need to call <a href="#makeCurrent">makeCurrent</a>() because this has already
been done when this function is called.
<h3 class=fn>void <a name="paintOverlayGL"></a>TQGLWidget::paintOverlayGL ()<tt> [virtual protected]</tt>
</h3>
This virtual function is used in the same manner as <a href="#paintGL">paintGL</a>()
except that it operates on the widget's overlay context instead of
the widget's main context. This means that <a href="#paintOverlayGL">paintOverlayGL</a>() is
called whenever the widget's overlay needs to be painted.
Reimplement it in a subclass.
<p> There is no need to call <a href="#makeOverlayCurrent">makeOverlayCurrent</a>() because this has
already been done when this function is called.
<h3 class=fn>void <a name="qglClearColor"></a>TQGLWidget::qglClearColor ( const <a href="ntqcolor.html">TQColor</a> & c ) const
</h3>
Convenience function for specifying the clearing color to OpenGL.
Calls glClearColor (in RGBA mode) or glClearIndex (in color-index
mode) with the color <em>c</em>. Applies to the current GL context.
<p> <p>See also <a href="#qglColor">qglColor</a>(), <a href="qglcontext.html#currentContext">TQGLContext::currentContext</a>(), and <a href="ntqcolor.html">TQColor</a>.
<h3 class=fn>void <a name="qglColor"></a>TQGLWidget::qglColor ( const <a href="ntqcolor.html">TQColor</a> & c ) const
</h3>
Convenience function for specifying a drawing color to OpenGL.
Calls glColor3 (in RGBA mode) or glIndex (in color-index mode)
with the color <em>c</em>. Applies to the current GL context.
<p> <p>See also <a href="#qglClearColor">qglClearColor</a>(), <a href="qglcontext.html#currentContext">TQGLContext::currentContext</a>(), and <a href="ntqcolor.html">TQColor</a>.
<h3 class=fn><a href="ntqpixmap.html">TQPixmap</a> <a name="renderPixmap"></a>TQGLWidget::renderPixmap ( int w = 0, int h = 0, bool useContext = FALSE )<tt> [virtual]</tt>
</h3>
Renders the current scene on a pixmap and returns the pixmap.
<p> You can use this method on both visible and invisible TQGLWidgets.
<p> This method will create a pixmap and a temporary <a href="qglcontext.html">TQGLContext</a> to
render on the pixmap. It will then call <a href="#initializeGL">initializeGL</a>(),
<a href="#resizeGL">resizeGL</a>(), and <a href="#paintGL">paintGL</a>() on this context. Finally, the widget's
original GL context is restored.
<p> The size of the pixmap will be <em>w</em> pixels wide and <em>h</em> pixels
high unless one of these parameters is 0 (the default), in which
case the pixmap will have the same size as the widget.
<p> If <em>useContext</em> is TRUE, this method will try to be more
efficient by using the existing GL context to render the pixmap.
The default is FALSE. Only use TRUE if you understand the risks.
<p> Overlays are not rendered onto the pixmap.
<p> If the GL rendering context and the desktop have different bit
depths, the result will most likely look surprising.
<p> Note that the creation of display lists, modifications of the view
frustum etc. should be done from within initializeGL(). If this is
not done, the temporary TQGLContext will not be initialized
properly, and the rendered pixmap may be incomplete/corrupted.
<h3 class=fn>void <a name="renderText"></a>TQGLWidget::renderText ( int x, int y, const <a href="ntqstring.html">TQString</a> & str, const <a href="ntqfont.html">TQFont</a> & fnt = TQFont ( ), int listBase = 2000 )
</h3>
Renders the string <em>str</em> into the GL context of this widget.
<p> <em>x</em> and <em>y</em> are specified in window coordinates, with the origin
in the upper left-hand corner of the window. If <em>fnt</em> is not
specified, the currently set application font will be used to
render the string. To change the color of the rendered text you can
use the glColor() call (or the <a href="#qglColor">qglColor</a>() convenience function),
just before the <a href="#renderText">renderText</a>() call. Note that if you have
GL_LIGHTING enabled, the string will not appear in the color you
want. You should therefore switch lighting off before using
renderText().
<p> <em>listBase</em> specifies the index of the first display list that is
generated by this function. The default value is 2000. 256 display
lists will be generated, one for each of the first 256 characters
in the font that is used to render the string. If several fonts are
used in the same widget, the display lists for these fonts will
follow the last generated list. You would normally not have to
change this value unless you are using lists in the same range. The
lists are deleted when the widget is destroyed.
<p> Note: This function only works reliably with ASCII strings.
<h3 class=fn>void <a name="renderText-2"></a>TQGLWidget::renderText ( double x, double y, double z, const <a href="ntqstring.html">TQString</a> & str, const <a href="ntqfont.html">TQFont</a> & fnt = TQFont ( ), int listBase = 2000 )
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <em>x</em>, <em>y</em> and <em>z</em> are specified in scene or object coordinates
relative to the currently set projection and model matrices. This
can be useful if you want to annotate models with text labels and
have the labels move with the model as it is rotated etc.
<h3 class=fn>void <a name="resizeEvent"></a>TQGLWidget::resizeEvent ( <a href="qresizeevent.html">TQResizeEvent</a> * )<tt> [virtual protected]</tt>
</h3>
<p> Handles resize events. Calls the virtual function <a href="#resizeGL">resizeGL</a>().
<p>Reimplemented from <a href="ntqwidget.html#resizeEvent">TQWidget</a>.
<h3 class=fn>void <a name="resizeGL"></a>TQGLWidget::resizeGL ( int width, int height )<tt> [virtual protected]</tt>
</h3>
<p> This virtual function is called whenever the widget has been
resized. The new size is passed in <em>width</em> and <em>height</em>.
Reimplement it in a subclass.
<p> There is no need to call <a href="#makeCurrent">makeCurrent</a>() because this has already
been done when this function is called.
<h3 class=fn>void <a name="resizeOverlayGL"></a>TQGLWidget::resizeOverlayGL ( int width, int height )<tt> [virtual protected]</tt>
</h3>
<p> This virtual function is used in the same manner as <a href="#paintGL">paintGL</a>()
except that it operates on the widget's overlay context instead of
the widget's main context. This means that <a href="#resizeOverlayGL">resizeOverlayGL</a>() is
called whenever the widget has been resized. The new size is
passed in <em>width</em> and <em>height</em>. Reimplement it in a subclass.
<p> There is no need to call <a href="#makeOverlayCurrent">makeOverlayCurrent</a>() because this has
already been done when this function is called.
<h3 class=fn>void <a name="setAutoBufferSwap"></a>TQGLWidget::setAutoBufferSwap ( bool on )<tt> [protected]</tt>
</h3>
<p> If <em>on</em> is TRUE automatic GL buffer swapping is switched on;
otherwise it is switched off.
<p> If <em>on</em> is TRUE and the widget is using a double-buffered format,
the background and foreground GL buffers will automatically be
swapped after each <a href="#paintGL">paintGL</a>() call.
<p> The buffer auto-swapping is on by default.
<p> <p>See also <a href="#autoBufferSwap">autoBufferSwap</a>(), <a href="#doubleBuffer">doubleBuffer</a>(), and <a href="#swapBuffers">swapBuffers</a>().
<h3 class=fn>void <a name="setColormap"></a>TQGLWidget::setColormap ( const <a href="ntqglcolormap.html">TQGLColormap</a> & cmap )
</h3>
<p> Set the colormap for this widget to <em>cmap</em>. Usually it is only
top-level widgets that can have colormaps installed.
<p> <p>See also <a href="#colormap">colormap</a>().
<h3 class=fn>void <a name="swapBuffers"></a>TQGLWidget::swapBuffers ()<tt> [virtual]</tt>
</h3>
<p> Swaps the screen contents with an off-screen buffer. This only
works if the widget's format specifies double buffer mode.
<p> Normally, there is no need to explicitly call this function
because it is done automatically after each widget repaint, i.e.
each time after <a href="#paintGL">paintGL</a>() has been executed.
<p> <p>See also <a href="#doubleBuffer">doubleBuffer</a>(), <a href="#setAutoBufferSwap">setAutoBufferSwap</a>(), and <a href="qglformat.html#setDoubleBuffer">TQGLFormat::setDoubleBuffer</a>().
<h3 class=fn>void <a name="updateGL"></a>TQGLWidget::updateGL ()<tt> [virtual slot]</tt>
</h3>
<p> Updates the widget by calling <a href="#glDraw">glDraw</a>().
<h3 class=fn>void <a name="updateOverlayGL"></a>TQGLWidget::updateOverlayGL ()<tt> [virtual slot]</tt>
</h3>
<p> Updates the widget's overlay (if any). Will cause the virtual
function <a href="#paintOverlayGL">paintOverlayGL</a>() to be executed.
<p> The widget's rendering context will become the current context and
<a href="#initializeGL">initializeGL</a>() will be called if it hasn't already been called.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright © 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>
|