~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qglwidget.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/opengl/qgl.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QGLWidget Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QGLWidget Class Reference</h1>
 
21
<p>The QGLWidget class is a widget for rendering OpenGL graphics. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QGLWidget&gt;</pre><p>Part of the <a href="qtopengl.html">QtOpenGL</a> module.</p>
 
23
<p>Inherits <a href="qwidget.html">QWidget</a>.</p>
 
24
<ul>
 
25
<li><a href="qglwidget-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qglwidget-obsolete.html">Obsolete members</a></li>
 
27
<li><a href="qglwidget-qt3.html">Qt 3 support members</a></li>
 
28
</ul>
 
29
<a name="public-functions"></a>
 
30
<h3>Public Functions</h3>
 
31
<ul>
 
32
<li><div class="fn"/><b><a href="qglwidget.html#QGLWidget">QGLWidget</a></b> ( QWidget * <i>parent</i> = 0, const QGLWidget * <i>shareWidget</i> = 0, Qt::WFlags <i>f</i> = 0 )</li>
 
33
<li><div class="fn"/><b><a href="qglwidget.html#QGLWidget-2">QGLWidget</a></b> ( QGLContext * <i>context</i>, QWidget * <i>parent</i> = 0, const QGLWidget * <i>shareWidget</i> = 0, Qt::WFlags <i>f</i> = 0 )</li>
 
34
<li><div class="fn"/><b><a href="qglwidget.html#QGLWidget-3">QGLWidget</a></b> ( const QGLFormat &amp; <i>format</i>, QWidget * <i>parent</i> = 0, const QGLWidget * <i>shareWidget</i> = 0, Qt::WFlags <i>f</i> = 0 )</li>
 
35
<li><div class="fn"/><b><a href="qglwidget.html#dtor.QGLWidget">~QGLWidget</a></b> ()</li>
 
36
<li><div class="fn"/>GLuint <b><a href="qglwidget.html#bindTexture">bindTexture</a></b> ( const QImage &amp; <i>image</i>, GLenum <i>target</i> = GL_TEXTURE_2D, GLint <i>format</i> = GL_RGBA8 )</li>
 
37
<li><div class="fn"/>GLuint <b><a href="qglwidget.html#bindTexture-2">bindTexture</a></b> ( const QPixmap &amp; <i>pixmap</i>, GLenum <i>target</i> = GL_TEXTURE_2D, GLint <i>format</i> = GL_RGBA8 )</li>
 
38
<li><div class="fn"/>GLuint <b><a href="qglwidget.html#bindTexture-3">bindTexture</a></b> ( const QString &amp; <i>fileName</i> )</li>
 
39
<li><div class="fn"/>const QGLColormap &amp; <b><a href="qglwidget.html#colormap">colormap</a></b> () const</li>
 
40
<li><div class="fn"/>const QGLContext * <b><a href="qglwidget.html#context">context</a></b> () const</li>
 
41
<li><div class="fn"/>void <b><a href="qglwidget.html#deleteTexture">deleteTexture</a></b> ( GLuint <i>id</i> )</li>
 
42
<li><div class="fn"/>void <b><a href="qglwidget.html#doneCurrent">doneCurrent</a></b> ()</li>
 
43
<li><div class="fn"/>bool <b><a href="qglwidget.html#doubleBuffer">doubleBuffer</a></b> () const</li>
 
44
<li><div class="fn"/>QGLFormat <b><a href="qglwidget.html#format">format</a></b> () const</li>
 
45
<li><div class="fn"/>QImage <b><a href="qglwidget.html#grabFrameBuffer">grabFrameBuffer</a></b> ( bool <i>withAlpha</i> = false )</li>
 
46
<li><div class="fn"/>bool <b><a href="qglwidget.html#isSharing">isSharing</a></b> () const</li>
 
47
<li><div class="fn"/>bool <b><a href="qglwidget.html#isValid">isValid</a></b> () const</li>
 
48
<li><div class="fn"/>void <b><a href="qglwidget.html#makeCurrent">makeCurrent</a></b> ()</li>
 
49
<li><div class="fn"/>void <b><a href="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a></b> ()</li>
 
50
<li><div class="fn"/>const QGLContext * <b><a href="qglwidget.html#overlayContext">overlayContext</a></b> () const</li>
 
51
<li><div class="fn"/>void <b><a href="qglwidget.html#qglClearColor">qglClearColor</a></b> ( const QColor &amp; <i>c</i> ) const</li>
 
52
<li><div class="fn"/>void <b><a href="qglwidget.html#qglColor">qglColor</a></b> ( const QColor &amp; <i>c</i> ) const</li>
 
53
<li><div class="fn"/>QPixmap <b><a href="qglwidget.html#renderPixmap">renderPixmap</a></b> ( int <i>w</i> = 0, int <i>h</i> = 0, bool <i>useContext</i> = false )</li>
 
54
<li><div class="fn"/>void <b><a href="qglwidget.html#renderText">renderText</a></b> ( int <i>x</i>, int <i>y</i>, const QString &amp; <i>str</i>, const QFont &amp; <i>fnt</i> = QFont(), int <i>listBase</i> = 2000 )</li>
 
55
<li><div class="fn"/>void <b><a href="qglwidget.html#renderText-2">renderText</a></b> ( double <i>x</i>, double <i>y</i>, double <i>z</i>, const QString &amp; <i>str</i>, const QFont &amp; <i>fnt</i> = QFont(), int <i>listBase</i> = 2000 )</li>
 
56
<li><div class="fn"/>void <b><a href="qglwidget.html#setColormap">setColormap</a></b> ( const QGLColormap &amp; <i>cmap</i> )</li>
 
57
<li><div class="fn"/>void <b><a href="qglwidget.html#setMouseTracking">setMouseTracking</a></b> ( bool <i>enable</i> )</li>
 
58
<li><div class="fn"/>void <b><a href="qglwidget.html#swapBuffers">swapBuffers</a></b> ()</li>
 
59
</ul>
 
60
<ul>
 
61
<li><div class="fn"/>183 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
 
62
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
63
<li><div class="fn"/>10 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
 
64
</ul>
 
65
<a name="public-slots"></a>
 
66
<h3>Public Slots</h3>
 
67
<ul>
 
68
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#updateGL">updateGL</a></b> ()</li>
 
69
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#updateOverlayGL">updateOverlayGL</a></b> ()</li>
 
70
</ul>
 
71
<ul>
 
72
<li><div class="fn"/>17 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
 
73
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
74
</ul>
 
75
<a name="static-public-members"></a>
 
76
<h3>Static Public Members</h3>
 
77
<ul>
 
78
<li><div class="fn"/>QImage <b><a href="qglwidget.html#convertToGLFormat">convertToGLFormat</a></b> ( const QImage &amp; <i>img</i> )</li>
 
79
</ul>
 
80
<ul>
 
81
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
 
82
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
83
</ul>
 
84
<a name="protected-functions"></a>
 
85
<h3>Protected Functions</h3>
 
86
<ul>
 
87
<li><div class="fn"/>bool <b><a href="qglwidget.html#autoBufferSwap">autoBufferSwap</a></b> () const</li>
 
88
<li><div class="fn"/>int <b><a href="qglwidget.html#fontDisplayListBase">fontDisplayListBase</a></b> ( const QFont &amp; <i>fnt</i>, int <i>listBase</i> = 2000 )</li>
 
89
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#glDraw">glDraw</a></b> ()</li>
 
90
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#glInit">glInit</a></b> ()</li>
 
91
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#initializeGL">initializeGL</a></b> ()</li>
 
92
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#initializeOverlayGL">initializeOverlayGL</a></b> ()</li>
 
93
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#paintEvent">paintEvent</a></b> ( QPaintEvent * <i>event</i> )</li>
 
94
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#paintGL">paintGL</a></b> ()</li>
 
95
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a></b> ()</li>
 
96
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#resizeEvent">resizeEvent</a></b> ( QResizeEvent * <i>event</i> )</li>
 
97
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#resizeGL">resizeGL</a></b> ( int <i>width</i>, int <i>height</i> )</li>
 
98
<li><div class="fn"/>virtual void <b><a href="qglwidget.html#resizeOverlayGL">resizeOverlayGL</a></b> ( int <i>width</i>, int <i>height</i> )</li>
 
99
<li><div class="fn"/>void <b><a href="qglwidget.html#setAutoBufferSwap">setAutoBufferSwap</a></b> ( bool <i>on</i> )</li>
 
100
</ul>
 
101
<ul>
 
102
<li><div class="fn"/>39 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
 
103
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
104
</ul>
 
105
<h3>Additional Inherited Members</h3>
 
106
<ul>
 
107
<li><div class="fn"/>52 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
 
108
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
109
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
 
110
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
111
</ul>
 
112
<a name="details"></a>
 
113
<hr />
 
114
<h2>Detailed Description</h2>
 
115
<p>The QGLWidget class is a widget for rendering OpenGL graphics.</p>
 
116
<p>QGLWidget provides functionality for displaying OpenGL </p>
 
117
<!-- <p>OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.</p>
 
118
--> graphics integrated into a Qt application. It is very simple to use. You inherit from it and use the subclass like any other <a href="qwidget.html">QWidget</a>, except that instead of drawing the widget's contents using <a href="qpainter.html">QPainter</a> etc. you use the standard OpenGL rendering commands.<p>QGLWidget provides three convenient virtual functions that you can reimplement in your subclass to perform the typical OpenGL tasks:</p>
 
119
<ul>
 
120
<li><a href="qglwidget.html#paintGL">paintGL</a>() - Renders the OpenGL scene. Gets called whenever the widget needs to be updated.</li>
 
121
<li><a href="qglwidget.html#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>
 
122
<li><a href="qglwidget.html#initializeGL">initializeGL</a>() - Sets up the OpenGL rendering context, defines display lists, etc. Gets called once before the first time <a href="qglwidget.html#resizeGL">resizeGL</a>() or <a href="qglwidget.html#paintGL">paintGL</a>() is called.</li>
 
123
</ul>
 
124
<p>Here is a rough outline of how a QGLWidget subclass might look:</p>
 
125
<pre>&nbsp;   class MyGLDrawer : public QGLWidget
 
126
    {
 
127
        Q_OBJECT        // must include this if you use Qt signals/slots
 
128
 
 
129
    public:
 
130
        MyGLDrawer(QWidget *parent)
 
131
            : QGLWidget(parent) {}
 
132
 
 
133
    protected:
 
134
 
 
135
        void initializeGL()
 
136
        {
 
137
            // Set up the rendering context, define display lists etc.:
 
138
            ...
 
139
            glClearColor(0.0, 0.0, 0.0, 0.0);
 
140
            glEnable(GL_DEPTH_TEST);
 
141
            ...
 
142
        }
 
143
 
 
144
        void resizeGL(int w, int h)
 
145
        {
 
146
            // setup viewport, projection etc.:
 
147
            glViewport(0, 0, (GLint)w, (GLint)h);
 
148
            ...
 
149
            glFrustum(...);
 
150
            ...
 
151
        }
 
152
 
 
153
        void paintGL()
 
154
        {
 
155
            // draw the scene:
 
156
            ...
 
157
            glRotatef(...);
 
158
            glMaterialfv(...);
 
159
            glBegin(GL_QUADS);
 
160
            glVertex3f(...);
 
161
            glVertex3f(...);
 
162
            ...
 
163
            glEnd();
 
164
            ...
 
165
        }
 
166
 
 
167
    };</pre>
 
168
<p>If you need to trigger a repaint from places other than <a href="qglwidget.html#paintGL">paintGL</a>() (a typical example is when using <a href="qtimer.html">timers</a> to animate scenes), you should call the widget's <a href="qglwidget.html#updateGL">updateGL</a>() function.</p>
 
169
<p>Your widget's OpenGL rendering context is made current when <a href="qglwidget.html#paintGL">paintGL</a>(), <a href="qglwidget.html#resizeGL">resizeGL</a>(), or <a href="qglwidget.html#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="qglwidget.html#makeCurrent">makeCurrent</a>() first.</p>
 
170
<p>QGLWidget 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>
 
171
<p>You can also share OpenGL display lists between QGLWidgets (see the documentation of the QGLWidget constructors for details).</p>
 
172
<a name="overlays"></a>
 
173
<h3>Overlays</h3>
 
174
<p>The QGLWidget creates a GL overlay context in addition to the normal context if overlays are supported by the underlying system.</p>
 
175
<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 QGLWidget constructor.) Your GL widget should also implement some or all of these virtual methods:</p>
 
176
<ul>
 
177
<li><a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a>()</li>
 
178
<li><a href="qglwidget.html#resizeOverlayGL">resizeOverlayGL</a>()</li>
 
179
<li><a href="qglwidget.html#initializeOverlayGL">initializeOverlayGL</a>()</li>
 
180
</ul>
 
181
<p>These methods work in the same way as the normal <a href="qglwidget.html#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="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a>(), and you can access the overlay context directly (e.g. to ask for its transparent color) by calling <a href="qglwidget.html#overlayContext">overlayContext</a>().</p>
 
182
<p>On X servers in which the default visual is in an overlay plane, non-GL Qt windows can also be used for overlays.</p>
 
183
<hr />
 
184
<h2>Member Function Documentation</h2>
 
185
<h3 class="fn"><a name="QGLWidget"></a>QGLWidget::QGLWidget ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const QGLWidget * <i>shareWidget</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = 0 )</h3>
 
186
<p>Constructs an OpenGL widget with a <i>parent</i> widget.</p>
 
187
<p>The <a href="qglformat.html#defaultFormat">default format</a> is used. The widget will be <a href="qglwidget.html#isValid">invalid</a> if the system has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.</p>
 
188
<p>The <i>parent</i> and widget flag, <i>f</i>, arguments are passed to the <a href="qwidget.html">QWidget</a> constructor.</p>
 
189
<p>If the <i>shareWidget</i> parameter points to a valid <a href="qglwidget.html">QGLWidget</a>, this widget will share OpenGL display lists with <i>shareWidget</i>. If this widget and <i>shareWidget</i> have different <a href="qglwidget.html#format">formats</a>, display list sharing may fail. You can check whether display list sharing succeeded by calling <a href="qglwidget.html#isSharing">isSharing</a>().</p>
 
190
<p>The initialization of OpenGL rendering state, etc. should be done by overriding the <a href="qglwidget.html#initializeGL">initializeGL</a>() function, rather than in the constructor of your <a href="qglwidget.html">QGLWidget</a> subclass.</p>
 
191
<p>See also <a href="qglformat.html#defaultFormat">QGLFormat::defaultFormat</a>().</p>
 
192
<h3 class="fn"><a name="QGLWidget-2"></a>QGLWidget::QGLWidget ( <a href="qglcontext.html">QGLContext</a> * <i>context</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const QGLWidget * <i>shareWidget</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = 0 )</h3>
 
193
<p>Constructs an OpenGL widget with parent <i>parent</i>.</p>
 
194
<p>The <i>context</i> argument is a pointer to the <a href="qglcontext.html">QGLContext</a> that you wish to be bound to this widget. This allows you to pass in your own <a href="qglcontext.html">QGLContext</a> sub-classes.</p>
 
195
<p>The widget will be <a href="qglwidget.html#isValid">invalid</a> if the system has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.</p>
 
196
<p>The <i>parent</i> and widget flag, <i>f</i>, arguments are passed to the <a href="qwidget.html">QWidget</a> constructor.</p>
 
197
<p>If the <i>shareWidget</i> parameter points to a valid <a href="qglwidget.html">QGLWidget</a>, this widget will share OpenGL display lists with <i>shareWidget</i>. If this widget and <i>shareWidget</i> have different <a href="qglwidget.html#format">formats</a>, display list sharing may fail. You can check whether display list sharing succeeded by calling <a href="qglwidget.html#isSharing">isSharing</a>().</p>
 
198
<p>The initialization of OpenGL rendering state, etc. should be done by overriding the <a href="qglwidget.html#initializeGL">initializeGL</a>() function, rather than in the constructor of your <a href="qglwidget.html">QGLWidget</a> subclass.</p>
 
199
<p>See also <a href="qglformat.html#defaultFormat">QGLFormat::defaultFormat</a>() and <a href="qglwidget.html#isValid">isValid</a>().</p>
 
200
<h3 class="fn"><a name="QGLWidget-3"></a>QGLWidget::QGLWidget ( const <a href="qglformat.html">QGLFormat</a> &amp; <i>format</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const QGLWidget * <i>shareWidget</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = 0 )</h3>
 
201
<p>Constructs an OpenGL widget with parent <i>parent</i>.</p>
 
202
<p>The <i>format</i> argument specifies the desired <a href="qglformat.html">rendering options</a>. If the underlying OpenGL/Window system cannot satisfy all the features requested in <i>format</i>, the nearest subset of features will be used. After creation, the <a href="qglwidget.html#format">format</a>() method will return the actual format obtained.</p>
 
203
<p>The widget will be <a href="qglwidget.html#isValid">invalid</a> if the system has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.</p>
 
204
<p>The <i>parent</i> and widget flag, <i>f</i>, arguments are passed to the <a href="qwidget.html">QWidget</a> constructor.</p>
 
205
<p>If the <i>shareWidget</i> parameter points to a valid <a href="qglwidget.html">QGLWidget</a>, this widget will share OpenGL display lists with <i>shareWidget</i>. If this widget and <i>shareWidget</i> have different <a href="qglwidget.html#format">formats</a>, display list sharing may fail. You can check whether display list sharing succeeded by calling <a href="qglwidget.html#isSharing">isSharing</a>().</p>
 
206
<p>The initialization of OpenGL rendering state, etc. should be done by overriding the <a href="qglwidget.html#initializeGL">initializeGL</a>() function, rather than in the constructor of your <a href="qglwidget.html">QGLWidget</a> subclass.</p>
 
207
<p>See also <a href="qglformat.html#defaultFormat">QGLFormat::defaultFormat</a>() and <a href="qglwidget.html#isValid">isValid</a>().</p>
 
208
<h3 class="fn"><a name="dtor.QGLWidget"></a>QGLWidget::~QGLWidget ()</h3>
 
209
<p>Destroys the widget.</p>
 
210
<h3 class="fn"><a name="autoBufferSwap"></a>bool QGLWidget::autoBufferSwap () const&nbsp;&nbsp;<tt> [protected]</tt></h3>
 
211
<p>Returns true if the widget is doing automatic GL buffer swapping; otherwise returns false.</p>
 
212
<p>See also <a href="qglwidget.html#setAutoBufferSwap">setAutoBufferSwap</a>().</p>
 
213
<h3 class="fn"><a name="bindTexture"></a>GLuint QGLWidget::bindTexture ( const <a href="qimage.html">QImage</a> &amp; <i>image</i>, GLenum <i>target</i> = GL_TEXTURE_2D, GLint <i>format</i> = GL_RGBA8 )</h3>
 
214
<p>Calls QGLContext:::bindTexture(<i>image</i>, <i>target</i>, <i>format</i>) on the currently set context.</p>
 
215
<p>See also <a href="qglwidget.html#deleteTexture">deleteTexture</a>().</p>
 
216
<h3 class="fn"><a name="bindTexture-2"></a>GLuint QGLWidget::bindTexture ( const <a href="qpixmap.html">QPixmap</a> &amp; <i>pixmap</i>, GLenum <i>target</i> = GL_TEXTURE_2D, GLint <i>format</i> = GL_RGBA8 )</h3>
 
217
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
218
<p>Calls QGLContext:::bindTexture(<i>pixmap</i>, <i>target</i>, <i>format</i>) on the currently set context.</p>
 
219
<p>See also <a href="qglwidget.html#deleteTexture">deleteTexture</a>().</p>
 
220
<h3 class="fn"><a name="bindTexture-3"></a>GLuint QGLWidget::bindTexture ( const <a href="qstring.html">QString</a> &amp; <i>fileName</i> )</h3>
 
221
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
222
<p>Calls QGLContext::bindTexture(<i>fileName</i>) on the currently set context.</p>
 
223
<p>See also <a href="qglwidget.html#deleteTexture">deleteTexture</a>().</p>
 
224
<h3 class="fn"><a name="colormap"></a>const <a href="qglcolormap.html">QGLColormap</a> &amp; QGLWidget::colormap () const</h3>
 
225
<p>Returns the colormap for this widget.</p>
 
226
<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>
 
227
<p>If no colormap has been set for this widget, the <a href="qcolormap.html">QColormap</a> returned will be empty.</p>
 
228
<p>See also <a href="qglwidget.html#setColormap">setColormap</a>().</p>
 
229
<h3 class="fn"><a name="context"></a>const <a href="qglcontext.html">QGLContext</a> * QGLWidget::context () const</h3>
 
230
<p>Returns the context of this widget.</p>
 
231
<p>It is possible that the context is not valid (see <a href="qglwidget.html#isValid">isValid</a>()), for example, if the underlying hardware does not support the format attributes that were requested.</p>
 
232
<h3 class="fn"><a name="convertToGLFormat"></a><a href="qimage.html">QImage</a> QGLWidget::convertToGLFormat ( const <a href="qimage.html">QImage</a> &amp; <i>img</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
233
<p>Converts the image <i>img</i> into the unnamed format expected by OpenGL functions such as glTexImage2D(). The returned image is not usable as a <a href="qimage.html">QImage</a>, but <a href="qimage.html#width">QImage::width</a>(), <a href="qimage.html#height">QImage::height</a>() and <a href="qimage.html#bits">QImage::bits</a>() may be used with OpenGL.</p>
 
234
<h3 class="fn"><a name="deleteTexture"></a>void QGLWidget::deleteTexture ( GLuint <i>id</i> )</h3>
 
235
<p>Calls QGLContext::deleteTexture(<i>id</i>) on the currently set context.</p>
 
236
<p>See also <a href="qglwidget.html#bindTexture">bindTexture</a>().</p>
 
237
<h3 class="fn"><a name="doneCurrent"></a>void QGLWidget::doneCurrent ()</h3>
 
238
<p>Makes no GL context the current context. Normally, you do not need to call this function; <a href="qglcontext.html">QGLContext</a> calls it as necessary. However, it may be useful in multithreaded environments.</p>
 
239
<h3 class="fn"><a name="doubleBuffer"></a>bool QGLWidget::doubleBuffer () const</h3>
 
240
<p>Returns true if the contained GL rendering context has double buffering; otherwise returns false.</p>
 
241
<p>See also <a href="qglformat.html#doubleBuffer">QGLFormat::doubleBuffer</a>().</p>
 
242
<h3 class="fn"><a name="fontDisplayListBase"></a>int QGLWidget::fontDisplayListBase ( const <a href="qfont.html">QFont</a> &amp; <i>fnt</i>, int <i>listBase</i> = 2000 )&nbsp;&nbsp;<tt> [protected]</tt></h3>
 
243
<p>Returns the value of the first display list that is generated for the characters in font <i>fnt</i>. <i>listBase</i> indicates the base value used when generating the display lists for the font. The default value is 2000.</p>
 
244
<h3 class="fn"><a name="format"></a><a href="qglformat.html">QGLFormat</a> QGLWidget::format () const</h3>
 
245
<p>Returns the format of the contained GL rendering context.</p>
 
246
<h3 class="fn"><a name="glDraw"></a>void QGLWidget::glDraw ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
247
<p>Executes the virtual function <a href="qglwidget.html#paintGL">paintGL</a>().</p>
 
248
<p>The widget's rendering context will become the current context and <a href="qglwidget.html#initializeGL">initializeGL</a>() will be called if it hasn't already been called.</p>
 
249
<h3 class="fn"><a name="glInit"></a>void QGLWidget::glInit ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
250
<p>Initializes OpenGL for this widget's context. Calls the virtual function <a href="qglwidget.html#initializeGL">initializeGL</a>().</p>
 
251
<h3 class="fn"><a name="grabFrameBuffer"></a><a href="qimage.html">QImage</a> QGLWidget::grabFrameBuffer ( bool <i>withAlpha</i> = false )</h3>
 
252
<p>Returns an image of the frame buffer. If <i>withAlpha</i> is true the alpha channel is included.</p>
 
253
<p>Depending on your hardware, you can explicitly select which color buffer to grab with a glReadBuffer() call before calling this function.</p>
 
254
<h3 class="fn"><a name="initializeGL"></a>void QGLWidget::initializeGL ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
255
<p>This virtual function is called once before the first call to <a href="qglwidget.html#paintGL">paintGL</a>() or <a href="qglwidget.html#resizeGL">resizeGL</a>(), and then once whenever the widget has been assigned a new <a href="qglcontext.html">QGLContext</a>. Reimplement it in a subclass.</p>
 
256
<p>This function should set up any required OpenGL context rendering flags, defining display lists, etc.</p>
 
257
<p>There is no need to call <a href="qglwidget.html#makeCurrent">makeCurrent</a>() because this has already been done when this function is called.</p>
 
258
<h3 class="fn"><a name="initializeOverlayGL"></a>void QGLWidget::initializeOverlayGL ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
259
<p>This virtual function is used in the same manner as <a href="qglwidget.html#initializeGL">initializeGL</a>() except that it operates on the widget's overlay context instead of the widget's main context. This means that initializeOverlayGL() is called once before the first call to <a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a>() or <a href="qglwidget.html#resizeOverlayGL">resizeOverlayGL</a>(). Reimplement it in a subclass.</p>
 
260
<p>This function should set up any required OpenGL context rendering flags, defining display lists, etc. for the overlay context.</p>
 
261
<p>There is no need to call <a href="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a>() because this has already been done when this function is called.</p>
 
262
<h3 class="fn"><a name="isSharing"></a>bool QGLWidget::isSharing () const</h3>
 
263
<p>Returns true if this widget's GL context is shared with another GL context, otherwise false is returned. The GL system may fail to provide context sharing if the two QGLWidgets use different formats.</p>
 
264
<p>See also <a href="qglwidget.html#format">format</a>().</p>
 
265
<h3 class="fn"><a name="isValid"></a>bool QGLWidget::isValid () const</h3>
 
266
<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>.</p>
 
267
<h3 class="fn"><a name="makeCurrent"></a>void QGLWidget::makeCurrent ()</h3>
 
268
<p>Makes this widget the current widget for OpenGL operations, i.e. makes the widget's rendering context the current OpenGL rendering context.</p>
 
269
<h3 class="fn"><a name="makeOverlayCurrent"></a>void QGLWidget::makeOverlayCurrent ()</h3>
 
270
<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="qglwidget.html#initializeOverlayGL">initializeOverlayGL</a>(), <a href="qglwidget.html#resizeOverlayGL">resizeOverlayGL</a>(), and <a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a>().</p>
 
271
<p>Does nothing if this widget has no overlay.</p>
 
272
<p>See also <a href="qglwidget.html#makeCurrent">makeCurrent</a>().</p>
 
273
<h3 class="fn"><a name="overlayContext"></a>const <a href="qglcontext.html">QGLContext</a> * QGLWidget::overlayContext () const</h3>
 
274
<p>Returns the overlay context of this widget, or 0 if this widget has no overlay.</p>
 
275
<p>See also <a href="qglwidget.html#context">context</a>().</p>
 
276
<h3 class="fn"><a name="paintEvent"></a>void QGLWidget::paintEvent ( <a href="qpaintevent.html">QPaintEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
277
<p>Handles paint events passed in the <i>event</i> parameter. Will cause the virtual <a href="qglwidget.html#paintGL">paintGL</a>() function to be called.</p>
 
278
<p>The widget's rendering context will become the current context and <a href="qglwidget.html#initializeGL">initializeGL</a>() will be called if it hasn't already been called.</p>
 
279
<p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget</a>.</p>
 
280
<h3 class="fn"><a name="paintGL"></a>void QGLWidget::paintGL ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
281
<p>This virtual function is called whenever the widget needs to be painted. Reimplement it in a subclass.</p>
 
282
<p>There is no need to call <a href="qglwidget.html#makeCurrent">makeCurrent</a>() because this has already been done when this function is called.</p>
 
283
<h3 class="fn"><a name="paintOverlayGL"></a>void QGLWidget::paintOverlayGL ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
284
<p>This virtual function is used in the same manner as <a href="qglwidget.html#paintGL">paintGL</a>() except that it operates on the widget's overlay context instead of the widget's main context. This means that paintOverlayGL() is called whenever the widget's overlay needs to be painted. Reimplement it in a subclass.</p>
 
285
<p>There is no need to call <a href="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a>() because this has already been done when this function is called.</p>
 
286
<h3 class="fn"><a name="qglClearColor"></a>void QGLWidget::qglClearColor ( const <a href="qcolor.html">QColor</a> &amp; <i>c</i> ) const</h3>
 
287
<p>Convenience function for specifying the clearing color to OpenGL. Calls glClearColor (in RGBA mode) or glClearIndex (in color-index mode) with the color <i>c</i>. Applies to the current GL context.</p>
 
288
<p>See also <a href="qglwidget.html#qglColor">qglColor</a>(), <a href="qglcontext.html#currentContext">QGLContext::currentContext</a>(), and <a href="qcolor.html">QColor</a>.</p>
 
289
<h3 class="fn"><a name="qglColor"></a>void QGLWidget::qglColor ( const <a href="qcolor.html">QColor</a> &amp; <i>c</i> ) const</h3>
 
290
<p>Convenience function for specifying a drawing color to OpenGL. Calls glColor4 (in RGBA mode) or glIndex (in color-index mode) with the color <i>c</i>. Applies to the current GL context.</p>
 
291
<p>See also <a href="qglwidget.html#qglClearColor">qglClearColor</a>(), <a href="qglcontext.html#currentContext">QGLContext::currentContext</a>(), and <a href="qcolor.html">QColor</a>.</p>
 
292
<h3 class="fn"><a name="renderPixmap"></a><a href="qpixmap.html">QPixmap</a> QGLWidget::renderPixmap ( int <i>w</i> = 0, int <i>h</i> = 0, bool <i>useContext</i> = false )</h3>
 
293
<p>Renders the current scene on a pixmap and returns the pixmap.</p>
 
294
<p>You can use this method on both visible and invisible QGLWidgets.</p>
 
295
<p>This method will create a pixmap and a temporary <a href="qglcontext.html">QGLContext</a> to render on the pixmap. It will then call <a href="qglwidget.html#initializeGL">initializeGL</a>(), <a href="qglwidget.html#resizeGL">resizeGL</a>(), and <a href="qglwidget.html#paintGL">paintGL</a>() on this context. Finally, the widget's original GL context is restored.</p>
 
296
<p>The size of the pixmap will be <i>w</i> pixels wide and <i>h</i> 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>
 
297
<p>If <i>useContext</i> 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>
 
298
<p>Overlays are not rendered onto the pixmap.</p>
 
299
<p>If the GL rendering context and the desktop have different bit depths, the result will most likely look surprising.</p>
 
300
<p>Note that the creation of display lists, modifications of the view frustum etc. should be done from within <a href="qglwidget.html#initializeGL">initializeGL</a>(). If this is not done, the temporary <a href="qglcontext.html">QGLContext</a> will not be initialized properly, and the rendered pixmap may be incomplete/corrupted.</p>
 
301
<h3 class="fn"><a name="renderText"></a>void QGLWidget::renderText ( int <i>x</i>, int <i>y</i>, const <a href="qstring.html">QString</a> &amp; <i>str</i>, const <a href="qfont.html">QFont</a> &amp; <i>fnt</i> = QFont(), int <i>listBase</i> = 2000 )</h3>
 
302
<p>Renders the string <i>str</i> into the GL context of this widget.</p>
 
303
<p><i>x</i> and <i>y</i> are specified in window coordinates, with the origin in the upper left-hand corner of the window. If <i>fnt</i> 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="qglwidget.html#qglColor">qglColor</a>() convenience function), just before the renderText() 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>
 
304
<p><i>listBase</i> 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>
 
305
<h3 class="fn"><a name="renderText-2"></a>void QGLWidget::renderText ( double <i>x</i>, double <i>y</i>, double <i>z</i>, const <a href="qstring.html">QString</a> &amp; <i>str</i>, const <a href="qfont.html">QFont</a> &amp; <i>fnt</i> = QFont(), int <i>listBase</i> = 2000 )</h3>
 
306
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
307
<p><i>x</i>, <i>y</i> and <i>z</i> 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.</p>
 
308
<h3 class="fn"><a name="resizeEvent"></a>void QGLWidget::resizeEvent ( <a href="qresizeevent.html">QResizeEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
309
<p>Handles resize events that are passed in the <i>event</i> parameter. Calls the virtual function <a href="qglwidget.html#resizeGL">resizeGL</a>().</p>
 
310
<p>Reimplemented from <a href="qwidget.html#resizeEvent">QWidget</a>.</p>
 
311
<h3 class="fn"><a name="resizeGL"></a>void QGLWidget::resizeGL ( int <i>width</i>, int <i>height</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
312
<p>This virtual function is called whenever the widget has been resized. The new size is passed in <i>width</i> and <i>height</i>. Reimplement it in a subclass.</p>
 
313
<p>There is no need to call <a href="qglwidget.html#makeCurrent">makeCurrent</a>() because this has already been done when this function is called.</p>
 
314
<h3 class="fn"><a name="resizeOverlayGL"></a>void QGLWidget::resizeOverlayGL ( int <i>width</i>, int <i>height</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
315
<p>This virtual function is used in the same manner as <a href="qglwidget.html#paintGL">paintGL</a>() except that it operates on the widget's overlay context instead of the widget's main context. This means that resizeOverlayGL() is called whenever the widget has been resized. The new size is passed in <i>width</i> and <i>height</i>. Reimplement it in a subclass.</p>
 
316
<p>There is no need to call <a href="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a>() because this has already been done when this function is called.</p>
 
317
<h3 class="fn"><a name="setAutoBufferSwap"></a>void QGLWidget::setAutoBufferSwap ( bool <i>on</i> )&nbsp;&nbsp;<tt> [protected]</tt></h3>
 
318
<p>If <i>on</i> is true automatic GL buffer swapping is switched on; otherwise it is switched off.</p>
 
319
<p>If <i>on</i> 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="qglwidget.html#paintGL">paintGL</a>() call.</p>
 
320
<p>The buffer auto-swapping is on by default.</p>
 
321
<p>See also <a href="qglwidget.html#autoBufferSwap">autoBufferSwap</a>(), <a href="qglwidget.html#doubleBuffer">doubleBuffer</a>(), and <a href="qglwidget.html#swapBuffers">swapBuffers</a>().</p>
 
322
<h3 class="fn"><a name="setColormap"></a>void QGLWidget::setColormap ( const <a href="qglcolormap.html">QGLColormap</a> &amp; <i>cmap</i> )</h3>
 
323
<p>Set the colormap for this widget to <i>cmap</i>. Usually it is only top-level widgets that can have colormaps installed.</p>
 
324
<p>See also <a href="qglwidget.html#colormap">colormap</a>().</p>
 
325
<h3 class="fn"><a name="setMouseTracking"></a>void QGLWidget::setMouseTracking ( bool <i>enable</i> )</h3>
 
326
<p>If <i>enable</i> is true then mouse tracking is enabled; otherwise it is disabled.</p>
 
327
<h3 class="fn"><a name="swapBuffers"></a>void QGLWidget::swapBuffers ()</h3>
 
328
<p>Swaps the screen contents with an off-screen buffer. This only works if the widget's format specifies double buffer mode.</p>
 
329
<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="qglwidget.html#paintGL">paintGL</a>() has been executed.</p>
 
330
<p>See also <a href="qglwidget.html#doubleBuffer">doubleBuffer</a>(), <a href="qglwidget.html#setAutoBufferSwap">setAutoBufferSwap</a>(), and <a href="qglformat.html#setDoubleBuffer">QGLFormat::setDoubleBuffer</a>().</p>
 
331
<h3 class="fn"><a name="updateGL"></a>void QGLWidget::updateGL ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
332
<p>Updates the widget by calling <a href="qglwidget.html#glDraw">glDraw</a>().</p>
 
333
<h3 class="fn"><a name="updateOverlayGL"></a>void QGLWidget::updateOverlayGL ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
334
<p>Updates the widget's overlay (if any). Will cause the virtual function <a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a>() to be executed.</p>
 
335
<p>The widget's rendering context will become the current context and <a href="qglwidget.html#initializeGL">initializeGL</a>() will be called if it hasn't already been called.</p>
 
336
<p /><address><hr /><div align="center">
 
337
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
338
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
339
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
340
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
341
</tr></table></div></address></body>
 
342
</html>