📄 qglcontext.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/opengl/qgl.cpp:701 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QGLContext Class</title><style type="text/css"><!--h3.fn,span.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><div class=fn><a href="#QGLContext"><b>QGLContext</b></a> ( const QGLFormat & format, QPaintDevice * device )</div></li><li><div class=fn>virtual <a href="#~QGLContext"><b>~QGLContext</b></a> ()</div></li><li><div class=fn>virtual bool <a href="#create"><b>create</b></a> ( const QGLContext * shareContext = 0 )</div></li><li><div class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</div></li><li><div class=fn>bool <a href="#isSharing"><b>isSharing</b></a> () const</div></li><li><div class=fn>virtual void <a href="#reset"><b>reset</b></a> ()</div></li><li><div class=fn>QGLFormat <a href="#format"><b>format</b></a> () const</div></li><li><div class=fn>QGLFormat <a href="#requestedFormat"><b>requestedFormat</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setFormat"><b>setFormat</b></a> ( const QGLFormat & format )</div></li><li><div class=fn>virtual void <a href="#makeCurrent"><b>makeCurrent</b></a> ()</div></li><li><div class=fn>virtual void <a href="#swapBuffers"><b>swapBuffers</b></a> () const</div></li><li><div class=fn>QPaintDevice * <a href="#device"><b>device</b></a> () const</div></li><li><div class=fn>QColor <a href="#overlayTransparentColor"><b>overlayTransparentColor</b></a> () const</div></li></ul><h2>Static Public Members</h2><ul><li><div class=fn>const QGLContext * <a href="#currentContext"><b>currentContext</b></a> ()</div></li></ul><h2>Protected Members</h2><ul><li><div class=fn>virtual bool <a href="#chooseContext"><b>chooseContext</b></a> ( const QGLContext * shareContext = 0 )</div></li><li><div class=fn>virtual void <a href="#doneCurrent"><b>doneCurrent</b></a> ()</div></li><li><div class=fn>virtual int <a href="#choosePixelFormat"><b>choosePixelFormat</b></a> ( void * dummyPfd, HDC pdc )</div></li><li><div class=fn>virtual void * <b>chooseMacVisual</b> ( GDHandle )</div></li><li><div class=fn>bool <a href="#deviceIsPixmap"><b>deviceIsPixmap</b></a> () const</div></li><li><div class=fn>bool <a href="#windowCreated"><b>windowCreated</b></a> () const</div></li><li><div class=fn>void <a href="#setWindowCreated"><b>setWindowCreated</b></a> ( bool on )</div></li><li><div class=fn>bool <a href="#initialized"><b>initialized</b></a> () const</div></li><li><div class=fn>void <a href="#setInitialized"><b>setInitialized</b></a> ( bool on )</div></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 OpenGLstate variables.<p> The context's <a href="qgl.html#FormatOption-enum">format</a> is set in theconstructor or later with <a href="#setFormat">setFormat</a>(). The format options that areactually set are returned by <a href="#format">format</a>(); the options you asked for arereturned by <a href="#requestedFormat">requestedFormat</a>(). Note that after a QGLContext objecthave been constructed, the actual OpenGL context have to be createdby explicitly calling the <a href="#create">create()</a>function. The <a href="#makeCurrent">makeCurrent</a>() function makes this context the currentrendering 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 makeit 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 withthe 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 theUnited 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>, whichcan be a widget or a pixmap. The <em>format</em> specifies several displayoptions for the context.<p> If the underlying OpenGL/Window system cannot satisfy all thefeatures requested in <em>format</em>, the nearest subset of features willbe used. After creation, the <a href="#format">format</a>() method will return the actualformat obtained.<p> Note that after a QGLContext object have been constructed, <a href="#create">create()</a> have to be called explicitly to create theactual OpenGL context. The context will be <a href="#isValid">invalid</a> if it was not possible to obtain a GL context atall.<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 asystem-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>(), whichfinds a matching pixel format identifier. On X11, it calls thevirtual function chooseVisual() which finds an appropriate X visual.On other platforms it may work differently.<h3 class=fn>int <a name="choosePixelFormat"></a>QGLContext::choosePixelFormat ( void * dummyPfd, HDC pdc )<tt> [virtual protected]</tt></h3> <p> <strong>Win32 only</strong> This virtual function chooses a pixel formatthat 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>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 increating a GL rendering context on the paint device specified in theconstructor; otherwise returns FALSE (i.e. the context is invalid).<p> After successful creation, <a href="#format">format</a>() returns the set of features ofthe created GL rendering context.<p> If <em>shareContext</em> points to a valid QGLContext, this method willtry to establish OpenGL display list sharing between this contextand the <em>shareContext</em>. Note that this may fail if the two contextshave different formats. Use <a href="#isSharing">isSharing</a>() to see if sharing succeeded.<p> <strong>Implementation note:</strong> initialization of C++ class membersusually takes place in the class constructor. QGLContext is an exceptionbecause it must be simple to customize. The virtual functions<a href="#chooseContext">chooseContext</a>() (and chooseVisual() for X11) can be reimplemented in asubclass to select a particular context. The problem is that virtualfunctions are not properly called during construction (even thoughthis is correct C++) because C++ constructs class hierarchies from thebottom up. For this reason we need a <a href="#create">create</a>() function.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -