You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
345 lines
18 KiB
345 lines
18 KiB
14 years ago
|
<!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:733 -->
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>QGLContext 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>QGLContext Class Reference<br><small>[<a href="opengl.html">OpenGL module</a>]</small></h1>
|
||
|
|
||
|
<p>The QGLContext class encapsulates an OpenGL rendering context.
|
||
|
<a href="#details">More...</a>
|
||
|
<p><tt>#include <<a href="qgl-h.html">qgl.h</a>></tt>
|
||
|
<p>Inherits <a href="qgl.html">QGL</a>.
|
||
|
<p><a href="qglcontext-members.html">List of all member functions.</a>
|
||
|
<h2>Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn><a href="#QGLContext"><b>QGLContext</b></a> ( const QGLFormat & format, QPaintDevice * device )</li>
|
||
|
<li class=fn>virtual <a href="#~QGLContext"><b>~QGLContext</b></a> ()</li>
|
||
|
<li class=fn>virtual bool <a href="#create"><b>create</b></a> ( const QGLContext * shareContext = 0 )</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="#reset"><b>reset</b></a> ()</li>
|
||
|
<li class=fn>QGLFormat <a href="#format"><b>format</b></a> () const</li>
|
||
|
<li class=fn>QGLFormat <a href="#requestedFormat"><b>requestedFormat</b></a> () const</li>
|
||
|
<li class=fn>virtual void <a href="#setFormat"><b>setFormat</b></a> ( const QGLFormat & format )</li>
|
||
|
<li class=fn>virtual void <a href="#makeCurrent"><b>makeCurrent</b></a> ()</li>
|
||
|
<li class=fn>virtual void <a href="#swapBuffers"><b>swapBuffers</b></a> () const</li>
|
||
|
<li class=fn>QPaintDevice * <a href="#device"><b>device</b></a> () const</li>
|
||
|
<li class=fn>QColor <a href="#overlayTransparentColor"><b>overlayTransparentColor</b></a> () const</li>
|
||
|
</ul>
|
||
|
<h2>Static Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn>const QGLContext * <a href="#currentContext"><b>currentContext</b></a> ()</li>
|
||
|
</ul>
|
||
|
<h2>Protected Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn>virtual bool <a href="#chooseContext"><b>chooseContext</b></a> ( const QGLContext * shareContext = 0 )</li>
|
||
|
<li class=fn>virtual void <a href="#doneCurrent"><b>doneCurrent</b></a> ()</li>
|
||
|
<li class=fn>virtual int <a href="#choosePixelFormat"><b>choosePixelFormat</b></a> ( void * dummyPfd, HDC pdc )</li>
|
||
|
<li class=fn>virtual void * <a href="#chooseVisual"><b>chooseVisual</b></a> ()</li>
|
||
|
<li class=fn>virtual void * <a href="#chooseMacVisual"><b>chooseMacVisual</b></a> ( GDHandle device )</li>
|
||
|
<li class=fn>bool <a href="#deviceIsPixmap"><b>deviceIsPixmap</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#windowCreated"><b>windowCreated</b></a> () const</li>
|
||
|
<li class=fn>void <a href="#setWindowCreated"><b>setWindowCreated</b></a> ( bool on )</li>
|
||
|
<li class=fn>bool <a href="#initialized"><b>initialized</b></a> () const</li>
|
||
|
<li class=fn>void <a href="#setInitialized"><b>setInitialized</b></a> ( bool on )</li>
|
||
|
<li class=fn>void <a href="#generateFontDisplayLists"><b>generateFontDisplayLists</b></a> ( const QFont & font, int listBase )</li>
|
||
|
</ul>
|
||
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
||
|
|
||
|
|
||
|
The QGLContext class encapsulates an OpenGL rendering context.
|
||
|
|
||
|
<p>
|
||
|
|
||
|
|
||
|
<p> An OpenGL<sup>*</sup> rendering context is a complete set of
|
||
|
OpenGL state variables.
|
||
|
<p> The context's <a href="qgl.html#FormatOption-enum">format</a> is set in the
|
||
|
constructor or later with <a href="#setFormat">setFormat</a>(). The format options that are
|
||
|
actually set are returned by <a href="#format">format</a>(); the options you asked for
|
||
|
are returned by <a href="#requestedFormat">requestedFormat</a>(). Note that after a QGLContext
|
||
|
object has been constructed, the actual OpenGL context must be
|
||
|
created by explicitly calling the <a href="#create">create()</a>
|
||
|
function. The <a href="#makeCurrent">makeCurrent</a>() function makes this context the
|
||
|
current rendering context. You can make <em>no</em> context current
|
||
|
using <a href="#doneCurrent">doneCurrent</a>(). The <a href="#reset">reset</a>() function will reset the context
|
||
|
and make it invalid.
|
||
|
<p> You can examine properties of the context with, e.g. <a href="#isValid">isValid</a>(),
|
||
|
<a href="#isSharing">isSharing</a>(), <a href="#initialized">initialized</a>(), <a href="#windowCreated">windowCreated</a>() and
|
||
|
<a href="#overlayTransparentColor">overlayTransparentColor</a>().
|
||
|
<p> If you're using double buffering you can swap the screen contents
|
||
|
with the off-screen buffer using <a href="#swapBuffers">swapBuffers</a>().
|
||
|
<p> Please note that QGLContext is not thread safe.
|
||
|
<p> <sup>*</sup> OpenGL is a trademark of Silicon Graphics, Inc. in the
|
||
|
United States and other countries.
|
||
|
<p> <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="QGLContext"></a>QGLContext::QGLContext ( const <a href="qglformat.html">QGLFormat</a> & format, <a href="qpaintdevice.html">QPaintDevice</a> * device )
|
||
|
</h3>
|
||
|
Constructs an OpenGL context for the paint device <em>device</em>, which
|
||
|
can be a widget or a pixmap. The <em>format</em> specifies several
|
||
|
display options for the context.
|
||
|
<p> 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> Note that after a QGLContext object has been constructed, <a href="#create">create()</a> must be called explicitly to create
|
||
|
the actual OpenGL context. The context will be <a href="#isValid">invalid</a> if it was not possible to obtain a GL context at
|
||
|
all.
|
||
|
<p> <p>See also <a href="#format">format</a>() and <a href="#isValid">isValid</a>().
|
||
|
|
||
|
<h3 class=fn><a name="~QGLContext"></a>QGLContext::~QGLContext ()<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Destroys the OpenGL context and frees its resources.
|
||
|
|
||
|
<h3 class=fn>bool <a name="chooseContext"></a>QGLContext::chooseContext ( const <a href="qglcontext.html">QGLContext</a> * shareContext = 0 )<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This semi-internal function is called by <a href="#create">create</a>(). It creates a
|
||
|
system-dependent OpenGL handle that matches the <a href="#format">format</a>() of <em>shareContext</em> as closely as possible.
|
||
|
<p> On Windows, it calls the virtual function <a href="#choosePixelFormat">choosePixelFormat</a>(),
|
||
|
which finds a matching pixel format identifier. On X11, it calls
|
||
|
the virtual function <a href="#chooseVisual">chooseVisual</a>() which finds an appropriate X
|
||
|
visual. On other platforms it may work differently.
|
||
|
|
||
|
<h3 class=fn>void * <a name="chooseMacVisual"></a>QGLContext::chooseMacVisual ( GDHandle device )<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> <strong>Mac only</strong>: This virtual function tries to find a
|
||
|
visual that matches the format using the given <em>device</em> handle,
|
||
|
reducing the demands if the original request cannot be met.
|
||
|
<p> 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.
|
||
|
<p> <p>See also <a href="#chooseContext">chooseContext</a>().
|
||
|
|
||
|
<h3 class=fn>int <a name="choosePixelFormat"></a>QGLContext::choosePixelFormat ( void * dummyPfd, HDC pdc )<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
<strong>Win32 only</strong> This virtual function chooses a pixel
|
||
|
format that matches the OpenGL <a href="#setFormat">format</a>.
|
||
|
Reimplement this function in a subclass if you need a custom
|
||
|
context.
|
||
|
<p> <b>Warning:</b> The <em>dummyPfd</em> pointer and <em>pdc</em> are used as a <tt>PIXELFORMATDESCRIPTOR*</tt>. We use <tt>void</tt> to avoid using
|
||
|
Windows-specific types in our header files.
|
||
|
<p> <p>See also <a href="#chooseContext">chooseContext</a>().
|
||
|
|
||
|
<h3 class=fn>void * <a name="chooseVisual"></a>QGLContext::chooseVisual ()<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
<strong>X11 only</strong>: This virtual function tries to find a
|
||
|
visual that matches the format, reducing the demands if the original
|
||
|
request cannot be met.
|
||
|
<p> 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.
|
||
|
<p> <p>See also <a href="#chooseContext">chooseContext</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="create"></a>QGLContext::create ( const <a href="qglcontext.html">QGLContext</a> * shareContext = 0 )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
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).
|
||
|
<p> After successful creation, <a href="#format">format</a>() returns the set of features of
|
||
|
the created GL rendering context.
|
||
|
<p> If <em>shareContext</em> points to a valid QGLContext, this method will
|
||
|
try to establish OpenGL display list sharing between this context
|
||
|
and the <em>shareContext</em>. Note that this may fail if the two
|
||
|
contexts have different formats. Use <a href="#isSharing">isSharing</a>() to see if sharing
|
||
|
succeeded.
|
||
|
<p> <b>Warning:</b> 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 <a href="#chooseContext">chooseContext</a>() (and <a href="#chooseVisual">chooseVisual</a>() 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 <a href="#create">create</a>() function.
|
||
|
<p> <p>See also <a href="#chooseContext">chooseContext</a>(), <a href="#format">format</a>(), and <a href="#isValid">isValid</a>().
|
||
|
|
||
|
<h3 class=fn>const <a href="qglcontext.html">QGLContext</a> * <a name="currentContext"></a>QGLContext::currentContext ()<tt> [static]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> Returns the current context, i.e. the context to which any OpenGL
|
||
|
commands will currently be directed. Returns 0 if no context is
|
||
|
current.
|
||
|
<p> <p>See also <a href="#makeCurrent">makeCurrent</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qpaintdevice.html">QPaintDevice</a> * <a name="device"></a>QGLContext::device () const
|
||
|
</h3>
|
||
|
|
||
|
<p> Returns the paint device set for this context.
|
||
|
<p> <p>See also <a href="#QGLContext">QGLContext::QGLContext</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="deviceIsPixmap"></a>QGLContext::deviceIsPixmap () const<tt> [protected]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> Returns TRUE if the paint device of this context is a pixmap;
|
||
|
otherwise returns FALSE.
|
||
|
|
||
|
<h3 class=fn>void <a name="doneCurrent"></a>QGLContext::doneCurrent ()<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> Makes no GL context the current context. Normally, you do not need
|
||
|
to call this function; QGLContext calls it as necessary.
|
||
|
|
||
|
<h3 class=fn><a href="qglformat.html">QGLFormat</a> <a name="format"></a>QGLContext::format () const
|
||
|
</h3>
|
||
|
|
||
|
<p> Returns the frame buffer format that was obtained (this may be a
|
||
|
subset of what was requested).
|
||
|
<p> <p>See also <a href="#requestedFormat">requestedFormat</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="generateFontDisplayLists"></a>QGLContext::generateFontDisplayLists ( const <a href="qfont.html">QFont</a> & font, int listBase )<tt> [protected]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> Generates a set of 256 display lists for the 256 first characters
|
||
|
in the font <em>font</em>. The first list will start at index <em>listBase</em>.
|
||
|
<p> <p>See also <a href="qglwidget.html#renderText">QGLWidget::renderText</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="initialized"></a>QGLContext::initialized () const<tt> [protected]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> Returns TRUE if this context has been initialized, i.e. if
|
||
|
<a href="qglwidget.html#initializeGL">QGLWidget::initializeGL</a>() has been performed on it; otherwise
|
||
|
returns FALSE.
|
||
|
<p> <p>See also <a href="#setInitialized">setInitialized</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="isSharing"></a>QGLContext::isSharing () const
|
||
|
</h3>
|
||
|
|
||
|
<p> Returns TRUE if display list sharing with another context was
|
||
|
requested in the <a href="#create">create</a>() 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.
|
||
|
|
||
|
<h3 class=fn>bool <a name="isValid"></a>QGLContext::isValid () const
|
||
|
</h3>
|
||
|
|
||
|
<p> Returns TRUE if a GL rendering context has been successfully
|
||
|
created; otherwise returns FALSE.
|
||
|
|
||
|
<h3 class=fn>void <a name="makeCurrent"></a>QGLContext::makeCurrent ()<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> Makes this context the current OpenGL rendering context. All GL
|
||
|
functions you call operate on this context until another context
|
||
|
is made current.
|
||
|
<p> In some very rare cases the underlying call may fail. If this
|
||
|
occurs an error message is output to stderr.
|
||
|
|
||
|
<h3 class=fn><a href="qcolor.html">QColor</a> <a name="overlayTransparentColor"></a>QGLContext::overlayTransparentColor () const
|
||
|
</h3>
|
||
|
|
||
|
<p> If this context is a valid context in an overlay plane, returns
|
||
|
the plane's transparent color. Otherwise returns an <a href="qcolor.html#isValid">invalid</a> color.
|
||
|
<p> The returned color's <a href="qcolor.html#pixel">pixel</a> value is
|
||
|
the index of the transparent color in the colormap of the overlay
|
||
|
plane. (Naturally, the color's RGB values are meaningless.)
|
||
|
<p> The returned <a href="qcolor.html">QColor</a> object will generally work as expected only
|
||
|
when passed as the argument to <a href="qglwidget.html#qglColor">QGLWidget::qglColor</a>() or
|
||
|
<a href="qglwidget.html#qglClearColor">QGLWidget::qglClearColor</a>(). Under certain circumstances it can
|
||
|
also be used to draw transparent graphics with a <a href="qpainter.html">QPainter</a>. See the
|
||
|
examples/opengl/overlay_x11 example for details.
|
||
|
|
||
|
<h3 class=fn><a href="qglformat.html">QGLFormat</a> <a name="requestedFormat"></a>QGLContext::requestedFormat () const
|
||
|
</h3>
|
||
|
|
||
|
<p> Returns the frame buffer format that was originally requested in
|
||
|
the constructor or <a href="#setFormat">setFormat</a>().
|
||
|
<p> <p>See also <a href="#format">format</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="reset"></a>QGLContext::reset ()<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> Resets the context and makes it invalid.
|
||
|
<p> <p>See also <a href="#create">create</a>() and <a href="#isValid">isValid</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="setFormat"></a>QGLContext::setFormat ( const <a href="qglformat.html">QGLFormat</a> & format )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Sets a <em>format</em> for this context. The context is <a href="#reset">reset</a>.
|
||
|
<p> Call <a href="#create">create</a>() to create a new GL context that tries to match the
|
||
|
new format.
|
||
|
<p> <pre>
|
||
|
QGLContext *cx;
|
||
|
// ...
|
||
|
<a href="qglformat.html">QGLFormat</a> f;
|
||
|
f.<a href="qglformat.html#setStereo">setStereo</a>( TRUE );
|
||
|
cx-><a href="#setFormat">setFormat</a>( f );
|
||
|
if ( !cx-><a href="#create">create</a>() )
|
||
|
exit(); // no OpenGL support, or cannot render on the specified paintdevice
|
||
|
if ( !cx-><a href="#format">format</a>().stereo() )
|
||
|
exit(); // could not create stereo context
|
||
|
</pre>
|
||
|
|
||
|
<p> <p>See also <a href="#format">format</a>(), <a href="#reset">reset</a>(), and <a href="#create">create</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="setInitialized"></a>QGLContext::setInitialized ( bool on )<tt> [protected]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> If <em>on</em> is TRUE the context has been initialized, i.e.
|
||
|
<a href="#setInitialized">QGLContext::setInitialized</a>() has been called on it. If <em>on</em> is
|
||
|
FALSE the context has not been initialized.
|
||
|
<p> <p>See also <a href="#initialized">initialized</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="setWindowCreated"></a>QGLContext::setWindowCreated ( bool on )<tt> [protected]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> If <em>on</em> is TRUE the context has had a window created for it. If
|
||
|
<em>on</em> is FALSE no window has been created for the context.
|
||
|
<p> <p>See also <a href="#windowCreated">windowCreated</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="swapBuffers"></a>QGLContext::swapBuffers () const<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> Swaps the screen contents with an off-screen buffer. Only works if
|
||
|
the context is in double buffer mode.
|
||
|
<p> <p>See also <a href="qglformat.html#setDoubleBuffer">QGLFormat::setDoubleBuffer</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="windowCreated"></a>QGLContext::windowCreated () const<tt> [protected]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> Returns TRUE if a window has been created for this context;
|
||
|
otherwise returns FALSE.
|
||
|
<p> <p>See also <a href="#setWindowCreated">setWindowCreated</a>().
|
||
|
|
||
|
<!-- eof -->
|
||
|
<hr><p>
|
||
|
This file is part of the <a href="index.html">Qt 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>Qt 3.3.8</div>
|
||
|
</table></div></address></body>
|
||
|
</html>
|