summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/tqglcontext.3qt
blob: 4f0dc3723227bdc47d0263c94b81610e7bce8ced (plain)
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
'\" t
.TH QGLContext 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
QGLContext \- Encapsulates an OpenGL rendering context
.SH SYNOPSIS
\fC#include <ntqgl.h>\fR
.PP
Inherits QGL.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQGLContext\fR ( const QGLFormat & format, QPaintDevice * device )"
.br
.ti -1c
.BI "virtual \fB~QGLContext\fR ()"
.br
.ti -1c
.BI "virtual bool \fBcreate\fR ( const QGLContext * shareContext = 0 )"
.br
.ti -1c
.BI "bool \fBisValid\fR () const"
.br
.ti -1c
.BI "bool \fBisSharing\fR () const"
.br
.ti -1c
.BI "virtual void \fBreset\fR ()"
.br
.ti -1c
.BI "QGLFormat \fBformat\fR () const"
.br
.ti -1c
.BI "QGLFormat \fBrequestedFormat\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetFormat\fR ( const QGLFormat & format )"
.br
.ti -1c
.BI "virtual void \fBmakeCurrent\fR ()"
.br
.ti -1c
.BI "virtual void \fBswapBuffers\fR () const"
.br
.ti -1c
.BI "QPaintDevice * \fBdevice\fR () const"
.br
.ti -1c
.BI "QColor \fBoverlayTransparentColor\fR () const"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "const QGLContext * \fBcurrentContext\fR ()"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "virtual bool \fBchooseContext\fR ( const QGLContext * shareContext = 0 )"
.br
.ti -1c
.BI "virtual void \fBdoneCurrent\fR ()"
.br
.ti -1c
.BI "virtual int \fBchoosePixelFormat\fR ( void * dummyPfd, HDC pdc )"
.br
.ti -1c
.BI "virtual void * \fBchooseVisual\fR ()"
.br
.ti -1c
.BI "virtual void * \fBchooseMacVisual\fR ( GDHandle device )"
.br
.ti -1c
.BI "bool \fBdeviceIsPixmap\fR () const"
.br
.ti -1c
.BI "bool \fBwindowCreated\fR () const"
.br
.ti -1c
.BI "void \fBsetWindowCreated\fR ( bool on )"
.br
.ti -1c
.BI "bool \fBinitialized\fR () const"
.br
.ti -1c
.BI "void \fBsetInitialized\fR ( bool on )"
.br
.ti -1c
.BI "void \fBgenerateFontDisplayLists\fR ( const QFont & font, int listBase )"
.br
.in -1c
.SH DESCRIPTION
The QGLContext class encapsulates an OpenGL rendering context.
.PP
An OpenGL<sup>*</sup> rendering context is a complete set of OpenGL state variables.
.PP
The context's format is set in the constructor or later with setFormat(). The format options that are actually set are returned by format(); the options you asked for are returned by requestedFormat(). Note that after a QGLContext object has been constructed, the actual OpenGL context must be created by explicitly calling the create() function. The makeCurrent() function makes this context the current rendering context. You can make \fIno\fR context current using doneCurrent(). The reset() function will reset the context and make it invalid.
.PP
You can examine properties of the context with, e.g. isValid(), isSharing(), initialized(), windowCreated() and overlayTransparentColor().
.PP
If you're using double buffering you can swap the screen contents with the off-screen buffer using swapBuffers().
.PP
Please note that QGLContext is not thread safe.
.PP
<sup>*</sup> OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.
.PP
See also Graphics Classes and Image Processing Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QGLContext::QGLContext ( const QGLFormat & format, QPaintDevice * device )"
Constructs an OpenGL context for the paint device \fIdevice\fR, which can be a widget or a pixmap. The \fIformat\fR specifies several display options for the context.
.PP
If the underlying OpenGL/Window system cannot satisfy all the features requested in \fIformat\fR, the nearest subset of features will be used. After creation, the format() method will return the actual format obtained.
.PP
Note that after a QGLContext object has been constructed, create() must be called explicitly to create the actual OpenGL context. The context will be invalid if it was not possible to obtain a GL context at all.
.PP
See also format() and isValid().
.SH "QGLContext::~QGLContext ()\fC [virtual]\fR"
Destroys the OpenGL context and frees its resources.
.SH "bool QGLContext::chooseContext ( const QGLContext * shareContext = 0 )\fC [virtual protected]\fR"
This semi-internal function is called by create(). It creates a system-dependent OpenGL handle that matches the format() of \fIshareContext\fR as closely as possible.
.PP
On Windows, it calls the virtual function choosePixelFormat(), which finds a matching pixel format identifier. On X11, it calls the virtual function chooseVisual() which finds an appropriate X visual. On other platforms it may work differently.
.SH "void * QGLContext::chooseMacVisual ( GDHandle device )\fC [virtual protected]\fR"
\fBMac only\fR: This virtual function tries to find a visual that matches the format using the given \fIdevice\fR handle, reducing the demands if the original request cannot be met.
.PP
The algorithm for reducing the demands of the format is quite simple-minded, so override this method in your subclass if your application has specific requirements on visual selection.
.PP
See also chooseContext().
.SH "int QGLContext::choosePixelFormat ( void * dummyPfd, HDC pdc )\fC [virtual protected]\fR"
\fBWin32 only\fR This virtual function chooses a pixel format that matches the OpenGL format. Reimplement this function in a subclass if you need a custom context.
.PP
\fBWarning:\fR The \fIdummyPfd\fR pointer and \fIpdc\fR are used as a \fCPIXELFORMATDESCRIPTOR*\fR. We use \fCvoid\fR to avoid using Windows-specific types in our header files.
.PP
See also chooseContext().
.SH "void * QGLContext::chooseVisual ()\fC [virtual protected]\fR"
\fBX11 only\fR: This virtual function tries to find a visual that matches the format, reducing the demands if the original request cannot be met.
.PP
The algorithm for reducing the demands of the format is quite simple-minded, so override this method in your subclass if your application has spcific requirements on visual selection.
.PP
See also chooseContext().
.SH "bool QGLContext::create ( const QGLContext * shareContext = 0 )\fC [virtual]\fR"
Creates the GL context. Returns TRUE if it was successful in creating a valid GL rendering context on the paint device specified in the constructor; otherwise returns FALSE (i.e. the context is invalid).
.PP
After successful creation, format() returns the set of features of the created GL rendering context.
.PP
If \fIshareContext\fR points to a valid QGLContext, this method will try to establish OpenGL display list sharing between this context and the \fIshareContext\fR. Note that this may fail if the two contexts have different formats. Use isSharing() to see if sharing succeeded.
.PP
\fBWarning:\fR Implementation note: initialization of C++ class members usually takes place in the class constructor. QGLContext is an exception because it must be simple to customize. The virtual functions chooseContext() (and chooseVisual() for X11) can be reimplemented in a subclass to select a particular context. The problem is that virtual functions are not properly called during construction (even though this is correct C++) because C++ constructs class hierarchies from the bottom up. For this reason we need a create() function.
.PP
See also chooseContext(), format(), and isValid().
.SH "const QGLContext * QGLContext::currentContext ()\fC [static]\fR"
Returns the current context, i.e. the context to which any OpenGL commands will currently be directed. Returns 0 if no context is current.
.PP
See also makeCurrent().
.SH "QPaintDevice * QGLContext::device () const"
Returns the paint device set for this context.
.PP
See also QGLContext::QGLContext().
.SH "bool QGLContext::deviceIsPixmap () const\fC [protected]\fR"
Returns TRUE if the paint device of this context is a pixmap; otherwise returns FALSE.
.SH "void QGLContext::doneCurrent ()\fC [virtual protected]\fR"
Makes no GL context the current context. Normally, you do not need to call this function; QGLContext calls it as necessary.
.SH "QGLFormat QGLContext::format () const"
Returns the frame buffer format that was obtained (this may be a subset of what was requested).
.PP
See also requestedFormat().
.SH "void QGLContext::generateFontDisplayLists ( const QFont & font, int listBase )\fC [protected]\fR"
Generates a set of 256 display lists for the 256 first characters in the font \fIfont\fR. The first list will start at index \fIlistBase\fR.
.PP
See also QGLWidget::renderText().
.SH "bool QGLContext::initialized () const\fC [protected]\fR"
Returns TRUE if this context has been initialized, i.e. if QGLWidget::initializeGL() has been performed on it; otherwise returns FALSE.
.PP
See also setInitialized().
.SH "bool QGLContext::isSharing () const"
Returns TRUE if display list sharing with another context was requested in the create() call and the GL system was able to fulfill this request; otherwise returns FALSE. Note that display list sharing might not be supported between contexts with different formats.
.SH "bool QGLContext::isValid () const"
Returns TRUE if a GL rendering context has been successfully created; otherwise returns FALSE.
.SH "void QGLContext::makeCurrent ()\fC [virtual]\fR"
Makes this context the current OpenGL rendering context. All GL functions you call operate on this context until another context is made current.
.PP
In some very rare cases the underlying call may fail. If this occurs an error message is output to stderr.
.SH "QColor QGLContext::overlayTransparentColor () const"
If this context is a valid context in an overlay plane, returns the plane's transparent color. Otherwise returns an invalid color.
.PP
The returned color's pixel value is the index of the transparent color in the colormap of the overlay plane. (Naturally, the color's RGB values are meaningless.)
.PP
The returned QColor object will generally work as expected only when passed as the argument to QGLWidget::qglColor() or QGLWidget::qglClearColor(). Under certain circumstances it can also be used to draw transparent graphics with a QPainter. See the examples/opengl/overlay_x11 example for details.
.SH "QGLFormat QGLContext::requestedFormat () const"
Returns the frame buffer format that was originally requested in the constructor or setFormat().
.PP
See also format().
.SH "void QGLContext::reset ()\fC [virtual]\fR"
Resets the context and makes it invalid.
.PP
See also create() and isValid().
.SH "void QGLContext::setFormat ( const QGLFormat & format )\fC [virtual]\fR"
Sets a \fIformat\fR for this context. The context is reset.
.PP
Call create() to create a new GL context that tries to match the new format.
.PP
.nf
.br
    QGLContext *cx;
.br
    //  ...
.br
    QGLFormat f;
.br
    f.setStereo( TRUE );
.br
    cx->setFormat( f );
.br
    if ( !cx->create() )
.br
        exit(); // no OpenGL support, or cannot render on the specified paintdevice
.br
    if ( !cx->format().stereo() )
.br
        exit(); // could not create stereo context
.br
.fi
.PP
See also format(), reset(), and create().
.SH "void QGLContext::setInitialized ( bool on )\fC [protected]\fR"
If \fIon\fR is TRUE the context has been initialized, i.e. QGLContext::setInitialized() has been called on it. If \fIon\fR is FALSE the context has not been initialized.
.PP
See also initialized().
.SH "void QGLContext::setWindowCreated ( bool on )\fC [protected]\fR"
If \fIon\fR is TRUE the context has had a window created for it. If \fIon\fR is FALSE no window has been created for the context.
.PP
See also windowCreated().
.SH "void QGLContext::swapBuffers () const\fC [virtual]\fR"
Swaps the screen contents with an off-screen buffer. Only works if the context is in double buffer mode.
.PP
See also QGLFormat::setDoubleBuffer().
.SH "bool QGLContext::windowCreated () const\fC [protected]\fR"
Returns TRUE if a window has been created for this context; otherwise returns FALSE.
.PP
See also setWindowCreated().

.SH "SEE ALSO"
.BR http://doc.trolltech.com/qglcontext.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 $QTDIR/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 (tqglcontext.3qt) and the Qt
version (3.3.8).