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

📄 qglwidget.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 2 页
字号:
.TPresizeOverlayGL().TPinitializeOverlayGL().PPThese methods work in the same way as the normal paintGL() 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 makeOverlayCurrent(), and you can access the overlay context directly (e.g. to ask for its transparent color) by calling overlayContext()..PPOn X servers in which the default visual is in an overlay plane, non-GL Qt windows can also be used for overlays. See the examples/opengl/overlay_x11 example program for details..PP<sup>*</sup> OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries..PPSee also Graphics Classes and Image Processing Classes..SH MEMBER FUNCTION DOCUMENTATION.SH "QGLWidget::QGLWidget ( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WFlags f = 0 )"Constructs an OpenGL widget with a \fIparent\fR widget and a \fIname\fR..PPThe default format is used. The widget will be invalid if the system has no OpenGL support..PPThe \fIparent\fR, \fIname\fR and widget flag, \fIf\fR, arguments are passed to the QWidget constructor..PPIf the \fIshareWidget\fR parameter points to a valid QGLWidget, this widget will share OpenGL display lists with \fIshareWidget\fR. If this widget and \fIshareWidget\fR have different formats, display list sharing may fail. You can check whether display list sharing succeeded by calling isSharing()..PPThe initialization of OpenGL rendering state, etc. should be done by overriding the initializeGL() function, rather than in the constructor of your QGLWidget subclass..PPSee also QGLFormat::defaultFormat()..SH "QGLWidget::QGLWidget ( const QGLFormat & format, QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WFlags f = 0 )"Constructs an OpenGL widget with parent \fIparent\fR, called \fIname\fR..PPThe \fIformat\fR argument specifies the desired rendering options. 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..PPThe widget will be invalid if the system has no OpenGL support..PPThe \fIparent\fR, \fIname\fR and widget flag, \fIf\fR, arguments are passed to the QWidget constructor..PPIf the \fIshareWidget\fR parameter points to a valid QGLWidget, this widget will share OpenGL display lists with \fIshareWidget\fR. If this widget and \fIshareWidget\fR have different formats, display list sharing may fail. You can check whether display list sharing succeeded by calling isSharing()..PPThe initialization of OpenGL rendering state, etc. should be done by overriding the initializeGL() function, rather than in the constructor of your QGLWidget subclass..PPSee also QGLFormat::defaultFormat() and isValid()..SH "QGLWidget::~QGLWidget ()"Destroys the widget..SH "bool QGLWidget::autoBufferSwap () const\fC [protected]\fR"Returns TRUE if the widget is doing automatic GL buffer swapping; otherwise returns FALSE..PPSee also setAutoBufferSwap()..SH "const QGLColormap & QGLWidget::colormap () const"Returns the colormap for this widget..PPUsually 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..PPIf no colormap has been set for this widget, the QColormap returned will be empty..PPSee also setColormap()..SH "const QGLContext * QGLWidget::context () const"Returns the context of this widget..PPIt is possible that the context is not valid (see isValid()), for example, if the underlying hardware does not support the format attributes that were requested..SH "QImage QGLWidget::convertToGLFormat ( const QImage & img )\fC [static]\fR"Converts the image \fIimg\fR into the unnamed format expected by OpenGL functions such as glTexImage2D(). The returned image is not usable as a QImage, but QImage::width(), QImage::height() and QImage::bits() may be used with OpenGL. The following few lines are from the texture example. Most of the code is irrelevant, so we just quote the relevant bits:.PP.nf.br        QImage tex1, tex2, buf;.br        if ( !buf.load( "gllogo.bmp" ) ) {  // Load first image from file.fi.PPWe create \fItex1\fR (and another variable) for OpenGL, and load a real image into \fIbuf\fR..PP.nf.br        tex1 = QGLWidget::convertToGLFormat( buf );  // flipped 32bit RGBA.fi.PPA few lines later, we convert \fIbuf\fR into OpenGL format and store it in \fItex1\fR..PP.nf.br        glTexImage2D( GL_TEXTURE_2D, 0, 3, tex1.width(), tex1.height(), 0,.br                      GL_RGBA, GL_UNSIGNED_BYTE, tex1.bits() );.fi.PPAnother function in the same example uses \fItex1\fR with OpenGL..PPExample: opengl/texture/gltexobj.cpp..SH "bool QGLWidget::doubleBuffer () const"Returns TRUE if the contained GL rendering context has double buffering; otherwise returns FALSE..PPSee also QGLFormat::doubleBuffer()..SH "QGLFormat QGLWidget::format () const"Returns the format of the contained GL rendering context..SH "void QGLWidget::glDraw ()\fC [virtual protected]\fR"Executes the virtual function paintGL()..PPThe widget's rendering context will become the current context and initializeGL() will be called if it hasn't already been called..SH "void QGLWidget::glInit ()\fC [virtual protected]\fR"Initializes OpenGL for this widget's context. Calls the virtual function initializeGL()..SH "QImage QGLWidget::grabFrameBuffer ( bool withAlpha = FALSE )\fC [virtual]\fR"Returns an image of the frame buffer. If \fIwithAlpha\fR is TRUE the alpha channel is included..PPDepending on your hardware, you can explicitly select which color buffer to grab with a glReadBuffer() call before calling this function..SH "void QGLWidget::initializeGL ()\fC [virtual protected]\fR"This virtual function is called once before the first call to paintGL() or resizeGL(), and then once whenever the widget has been assigned a new QGLContext. Reimplement it in a subclass..PPThis function should set up any required OpenGL context rendering flags, defining display lists, etc..PPThere is no need to call makeCurrent() because this has already been done when this function is called..SH "void QGLWidget::initializeOverlayGL ()\fC [virtual protected]\fR"This virtual function is used in the same manner as initializeGL() 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 paintOverlayGL() or resizeOverlayGL(). Reimplement it in a subclass..PPThis function should set up any required OpenGL context rendering flags, defining display lists, etc. for the overlay context..PPThere is no need to call makeOverlayCurrent() because this has already been done when this function is called..SH "bool QGLWidget::isSharing () const"Returns TRUE if display list sharing with another QGLWidget was requested in the constructor, and the GL system was able to provide it; otherwise returns FALSE. The GL system may fail to provide display list sharing if the two QGLWidgets use different formats..PPSee also format()..SH "bool QGLWidget::isValid () const"Returns TRUE if the widget has a valid GL rendering context; otherwise returns FALSE. A widget will be invalid if the system has no OpenGL support..SH "void QGLWidget::makeCurrent ()\fC [virtual]\fR"Makes this widget the current widget for OpenGL operations, i.e. makes the widget's rendering context the current OpenGL rendering context..SH "void QGLWidget::makeOverlayCurrent ()\fC [virtual]\fR"Makes the overlay context of this widget current. Use this if you need to issue OpenGL commands to the overlay context outside of initializeOverlayGL(), resizeOverlayGL(), and paintOverlayGL()..PPDoes nothing if this widget has no overlay..PPSee also makeCurrent()..SH "const QGLContext * QGLWidget::overlayContext () const"Returns the overlay context of this widget, or 0 if this widget has no overlay..PPSee also context()..SH "void QGLWidget::paintEvent ( QPaintEvent * )\fC [virtual protected]\fR"Handles paint events. Will cause the virtual paintGL() function to be called..PPThe widget's rendering context will become the current context and initializeGL() will be called if it hasn't already been called..PPReimplemented from QWidget..SH "void QGLWidget::paintGL ()\fC [virtual protected]\fR"This virtual function is called whenever the widget needs to be painted. Reimplement it in a subclass..PPThere is no need to call makeCurrent() because this has already been done when this function is called..SH "void QGLWidget::paintOverlayGL ()\fC [virtual protected]\fR"This virtual function is used in the same manner as paintGL() 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..PPThere is no need to call makeOverlayCurrent() because this has already been done when this function is called..SH "void QGLWidget::qglClearColor ( const QColor & c ) const"Convenience function for specifying the clearing color to OpenGL. Calls glClearColor (in RGBA mode) or glClearIndex (in color-index mode) with the color \fIc\fR. Applies to the current GL context..PPSee also qglColor(), QGLContext::currentContext(), and QColor..SH "void QGLWidget::qglColor ( const QColor & c ) const"Convenience function for specifying a drawing color to OpenGL. Calls glColor3 (in RGBA mode) or glIndex (in color-index mode) with the color \fIc\fR. Applies to the current GL context..PPSee also qglClearColor(), QGLContext::currentContext(), and QColor..SH "QPixmap QGLWidget::renderPixmap ( int w = 0, int h = 0, bool useContext = FALSE )\fC [virtual]\fR"Renders the current scene on a pixmap and returns the pixmap..PPYou can use this method on both visible and invisible QGLWidgets..PPThis method will create a pixmap and a temporary QGLContext to render on the pixmap. It will then call initializeGL(), resizeGL(), and paintGL() on this context. Finally, the widget's original GL context is restored..PPThe size of the pixmap will be \fIw\fR pixels wide and \fIh\fR pixels high unless one of these parameters is 0 (the default), in which case the pixmap will have the same size as the widget..PPIf \fIuseContext\fR 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..PPOverlays are not rendered onto the pixmap..PPIf the GL rendering context and the desktop have different bit depths, the result will most likely look surprising..PPNote that the creation of display lists, modifications of the view frustum etc. should be done from within initializeGL(). If this is not done, the temporary QGLContext will not be initialized properly, and the rendered pixmap may be incomplete/corrupted..SH "void QGLWidget::renderText ( int x, int y, const QString & str, const QFont & fnt = QFont ( ), int listBase = 2000 )"Renders the string \fIstr\fR into the GL context of this widget..PP\fIx\fR and \fIy\fR are specified in window coordinates, with the origin in the upper left-hand corner of the window. If \fIfnt\fR 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 qglColor() 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()..PP\fIlistBase\fR 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..SH "void QGLWidget::renderText ( double x, double y, double z, const QString & str, const QFont & fnt = QFont ( ), int listBase = 2000 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fIx\fR, \fIy\fR and \fIz\fR 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..SH "void QGLWidget::resizeEvent ( QResizeEvent * )\fC [virtual protected]\fR"Handles resize events. Calls the virtual function resizeGL()..PPReimplemented from QWidget..SH "void QGLWidget::resizeGL ( int width, int height )\fC [virtual protected]\fR"This virtual function is called whenever the widget has been resized. The new size is passed in \fIwidth\fR and \fIheight\fR. Reimplement it in a subclass..PPThere is no need to call makeCurrent() because this has already been done when this function is called..SH "void QGLWidget::resizeOverlayGL ( int width, int height )\fC [virtual protected]\fR"This virtual function is used in the same manner as paintGL() 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 \fIwidth\fR and \fIheight\fR. Reimplement it in a subclass..PPThere is no need to call makeOverlayCurrent() because this has already been done when this function is called..SH "void QGLWidget::setAutoBufferSwap ( bool on )\fC [protected]\fR"If \fIon\fR is TRUE automatic GL buffer swapping is switched on; otherwise it is switched off..PPIf \fIon\fR is TRUE and the widget is using a double-buffered format, the background and foreground GL buffers will automatically be swapped after each paintGL() call..PPThe buffer auto-swapping is on by default..PPSee also autoBufferSwap(), doubleBuffer(), and swapBuffers()..SH "void QGLWidget::setColormap ( const QGLColormap & cmap )"Set the colormap for this widget to \fIcmap\fR. Usually it is only top-level widgets that can have colormaps installed..PPSee also colormap()..SH "void QGLWidget::swapBuffers ()\fC [virtual]\fR"Swaps the screen contents with an off-screen buffer. This only works if the widget's format specifies double buffer mode..PPNormally, there is no need to explicitly call this function because it is done automatically after each widget repaint, i.e. each time after paintGL() has been executed..PPSee also doubleBuffer(), setAutoBufferSwap(), and QGLFormat::setDoubleBuffer()..SH "void QGLWidget::updateGL ()\fC [virtual slot]\fR"Updates the widget by calling glDraw()..SH "void QGLWidget::updateOverlayGL ()\fC [virtual slot]\fR"Updates the widget's overlay (if any). Will cause the virtual function paintOverlayGL() to be executed..PPThe widget's rendering context will become the current context andinitializeGL() will be called if it hasn't already been called..SH "SEE ALSO".BR http://doc.trolltech.com/qglwidget.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf 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..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qglwidget.3qt) and the Qtversion (3.1.1).

⌨️ 快捷键说明

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