⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qglwidget.html

📁 QT 下载资料仅供参考
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<p> It is possible that the context is not valid (see <a href="#isValid">isValid</a>()), forexample, if the underlying hardware does not support the formatattributes that were requested.<h3 class=fn><a href="qimage.html">QImage</a> <a name="convertToGLFormat"></a>QGLWidget::convertToGLFormat ( const&nbsp;<a href="qimage.html">QImage</a>&nbsp;&amp;&nbsp;img )<tt> [static]</tt></h3> Converts the image <em>img</em> into the unnamed format expected by OpenGLfunctions such as glTexImage2D(). The returned image is not usableas 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. The following few lines arefrom the texture example. Most of the code is irrelevant, so we justquote the few lines we want:<p> <pre>        <a href="qimage.html">QImage</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 realimage into <em>buf</em>.<p> <pre>    <a name="x2089"></a>    tex1 = QGLWidget::<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 itin <em>tex1</em>.<p> <pre>    <a name="x2092"></a><a name="x2091"></a>    glTexImage2D( GL_TEXTURE_2D, 0, 3, tex1.<a href="qimage.html#width">width</a>(), tex1.<a href="qimage.html#height">height</a>(), 0,    <a name="x2090"></a>                  GL_RGBA, GL_UNSIGNED_BYTE, tex1.<a href="qimage.html#bits">bits</a>() );</pre><p> Another function in the same example uses <em>tex1</em> with OpenGL.<p>Example: <a href="qglwidget.html#x2089">opengl/texture/gltexobj.cpp</a>.<h3 class=fn>bool <a name="doubleBuffer"></a>QGLWidget::doubleBuffer () const</h3>Returns TRUE if the contained GL rendering context has doublebuffering; otherwise returns FALSE.<p>See also <a href="qglformat.html#doubleBuffer">QGLFormat::doubleBuffer</a>().<h3 class=fn><a href="qglformat.html">QGLFormat</a> <a name="format"></a>QGLWidget::format () const</h3>Returns the format of the contained GL rendering context.<h3 class=fn>void <a name="glDraw"></a>QGLWidget::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>QGLWidget::glInit ()<tt> [virtual protected]</tt></h3>Initializes OpenGL for this widget's context. Calls the virtualfunction <a href="#initializeGL">initializeGL</a>().<h3 class=fn><a href="qimage.html">QImage</a> <a name="grabFrameBuffer"></a>QGLWidget::grabFrameBuffer ( bool&nbsp;withAlpha = FALSE )<tt> [virtual]</tt></h3>Returns an image of the frame buffer. If <em>withAlpha</em> is TRUE thealpha channel is included.<h3 class=fn>void <a name="initializeGL"></a>QGLWidget::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 hasbeen assigned a new <a href="qglcontext.html">QGLContext</a>.  Reimplement it in a subclass.<p> This function should set up any required OpenGL context renderingflags, defining display lists, etc.<p> There is no need to call <a href="#makeCurrent">makeCurrent</a>() because this has already beendone when this function is called.<h3 class=fn>void <a name="initializeOverlayGL"></a>QGLWidget::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 thewidget's main context. This means that <a href="#initializeOverlayGL">initializeOverlayGL</a>() is calledonce 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 renderingflags, defining display lists, etc. for the overlay context.<p> There is no need to call <a href="#makeOverlayCurrent">makeOverlayCurrent</a>() because this has alreadybeen done when this function is called.<h3 class=fn>bool <a name="isSharing"></a>QGLWidget::isSharing () const</h3><p> Returns TRUE if display list sharing with another QGLWidget wasrequested in the constructor, and the GL system was able to provideit; otherwise returns FALSE. The GL system may fail to provide displaylist sharing if the two QGLWidgets use different formats.<p> <p>See also <a href="#format">format</a>().<h3 class=fn>bool <a name="isValid"></a>QGLWidget::isValid () const</h3><p> Returns TRUE if the widget has a valid GL rendering context; otherwisereturns FALSE. A widget will be invalid if the system has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.<p> <h3 class=fn>void <a name="makeCurrent"></a>QGLWidget::makeCurrent ()<tt> [virtual]</tt></h3><p> Makes this widget the current widget for OpenGLoperations, i.e. makes the widget's rendering context the currentOpenGL rendering context.<h3 class=fn>void <a name="makeOverlayCurrent"></a>QGLWidget::makeOverlayCurrent ()<tt> [virtual]</tt></h3>Makes the overlay context of this widget current. Use this if youneed 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&nbsp;<a href="qglcontext.html">QGLContext</a>&nbsp;* <a name="overlayContext"></a>QGLWidget::overlayContext () const</h3>Returns the overlay context of this widget, or 0 if this widget hasno overlay.<p> <p>See also <a href="#context">context</a>().<h3 class=fn>void <a name="paintEvent"></a>QGLWidget::paintEvent ( <a href="qpaintevent.html">QPaintEvent</a>&nbsp;* )<tt> [virtual protected]</tt></h3>Handles paint events. Will cause the virtual <a href="#paintGL">paintGL</a>() function tobe 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="qwidget.html#paintEvent">QWidget</a>.<h3 class=fn>void <a name="paintGL"></a>QGLWidget::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 beendone when this function is called.<h3 class=fn>void <a name="paintOverlayGL"></a>QGLWidget::paintOverlayGL ()<tt> [virtual protected]</tt></h3>This virtual function is used in the same manner as <a href="#paintGL">paintGL</a>() exceptthat it operates on the widget's overlay context instead of thewidget's main context. This means that <a href="#paintOverlayGL">paintOverlayGL</a>() is calledwhenever 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 thishas already been done when this function is called.<h3 class=fn>void <a name="qglClearColor"></a>QGLWidget::qglClearColor ( const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;c ) const</h3>Convenience function for specifying the clearing color toOpenGL. Calls glClearColor (in RGBA mode) or glClearIndex (incolor-index mode) with the color <em>c</em>. Applies to the current GLcontext.<p> <p>See also <a href="#qglColor">qglColor</a>(), <a href="qglcontext.html#currentContext">QGLContext::currentContext</a>() and <a href="qcolor.html">QColor</a>.<h3 class=fn>void <a name="qglColor"></a>QGLWidget::qglColor ( const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;c ) const</h3>Convenience function for specifying a drawing color to OpenGL. CallsglColor3 (in RGBA mode) or glIndex (in color-index mode) with thecolor <em>c</em>. Applies to the current GL context.<p> <p>See also <a href="#qglClearColor">qglClearColor</a>(), <a href="qglcontext.html#currentContext">QGLContext::currentContext</a>() and <a href="qcolor.html">QColor</a>.<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="renderPixmap"></a>QGLWidget::renderPixmap ( int&nbsp;w = 0, int&nbsp;h = 0, bool&nbsp;useContext = FALSE )<tt> [virtual]</tt></h3>Renders the current scene on a pixmap and returns the pixmap.<p> You may use this method on both visible and invisible QGLWidgets.<p> This method will create a pixmap and a temporary <a href="qglcontext.html">QGLContext</a> to renderon 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 contextis restored.<p> The size of the pixmap will be <em>w</em> pixels wide and <em>h</em> pixels highunless one of these parameters is 0 (the default), in which case thepixmap will have the same size as the widget.<p> If <em>useContext</em> is TRUE, this method will try to be more efficientby using the existing GL context to render the pixmap. The defaultis 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 differentbit depths, the result will most likely look surprising.<p> Note that the creation of display lists, modifications of the viewfrustum etc. should be done from within initializeGL(). If this isnot done, the temporary QGLContext will not be initialized properly,and the rendered pixmap may be incomplete/corrupted.<h3 class=fn>void <a name="resizeEvent"></a>QGLWidget::resizeEvent ( <a href="qresizeevent.html">QResizeEvent</a>&nbsp;* )<tt> [virtual protected]</tt></h3>Handles resize events. Calls the virtual function <a href="#resizeGL">resizeGL</a>().<p>Reimplemented from <a href="qwidget.html#resizeEvent">QWidget</a>.<h3 class=fn>void <a name="resizeGL"></a>QGLWidget::resizeGL ( int&nbsp;width, int&nbsp;height )<tt> [virtual protected]</tt></h3>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 beendone when this function is called.<h3 class=fn>void <a name="resizeOverlayGL"></a>QGLWidget::resizeOverlayGL ( int&nbsp;width, int&nbsp;height )<tt> [virtual protected]</tt></h3>This virtual function is used in the same manner as <a href="#paintGL">paintGL</a>() exceptthat it operates on the widget's overlay context instead of thewidget's main context. This means that <a href="#resizeOverlayGL">resizeOverlayGL</a>() is calledwhenever 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>() becausethis has already been done when this function is called.<h3 class=fn>void <a name="setAutoBufferSwap"></a>QGLWidget::setAutoBufferSwap ( bool&nbsp;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, thebackground and foreground GL buffers will automatically be swappedafter each time the <a href="#paintGL">paintGL</a>() function has been called.<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>QGLWidget::setColormap ( const&nbsp;<a href="qglcolormap.html">QGLColormap</a>&nbsp;&amp;&nbsp;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>QGLWidget::swapBuffers ()<tt> [virtual]</tt></h3>Swaps the screen contents with an off-screen buffer. This only worksif the widget's format specifies double buffer mode.<p> Normally, there is no need to explicitly call this function becauseit is done automatically after each widget repaint, i.e. eachtime 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">QGLFormat::setDoubleBuffer</a>().<h3 class=fn>void <a name="updateGL"></a>QGLWidget::updateGL ()<tt> [virtual slot]</tt></h3>Updates the widget by calling <a href="#glDraw">glDraw</a>().<h3 class=fn>void <a name="updateOverlayGL"></a>QGLWidget::updateOverlayGL ()<tt> [virtual slot]</tt></h3>Updates the widget's overlay (if any). Will cause the virtualfunction <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">Qt toolkit</a>.Copyright &copy; 1995-2002<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 &copy; 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -