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

📄 qglwidget.3qt

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 3QT
📖 第 1 页 / 共 2 页
字号:
.br          glBegin( GL_QUADS );.br          glVertex3f( ... );.br          glVertex3f( ... );.br          ....br          glEnd();.br          ....br        }.br.br    };.fi.PPIf you need to trigger a repaint from other places than paintGL() (a typical example is when using timers to animate scenes), you should call the widget's updateGL() function..PPWhen paintGL(), resizeGL() or initializeGL() is called, your widget's OpenGL rendering context has been made current. If you need to call the standard OpenGL API functions from other places (e.g. in your widget's constructor), you must call makeCurrent() first..PPQGLWidget provides advanced functions for requesting a new display format, and you can even set a new rendering context..PPYou can achieve sharing of OpenGL display lists between QGLWidgets, see the documentation of the QGLWidget constructors for details..PP\fBAbout Overlays:\fR The QGLWidget can create a GL overlay context in addition to the normal context, if overlays are supported by the underlying system..PPIf you want to use overlays, you specify it in the format. (Note: Overlay must be requested in the format passed to the QGLWidget constructor). Your GL widget should also implement some or all of these virtual methods:.TPpaintOverlayGL().TPresizeOverlayGL().TPinitializeOverlayGL().PPThese methods work in the same way as the normal paintGL() & al. functions, only that they will be called when with the overlay context 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()..PPNote: QGLWidget overlay support is currently implemented only for the X11 window system. The Windows implementation is experimental..PPNote: On X servers where the default visual is in an overlay plane, non-GL Qt windows can also be used for overlays; see the "overlay_x11" example program for details..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, name\fR and \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 Note: If this widget and \fIshareWidget\fR has different formats, display list sharing may fail. You can check whether display list sharing succeeded by using the isSharing() method..PPNote: Initialization of OpenGL rendering state etc. should be done by overriding the initializeGL() function, not 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 a \fIparent\fR widget and a \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, name\fR and \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 Note: If this widget and \fIshareWidget\fR has different formats, display list sharing may fail. You can check whether display list sharing succeeded by using the isSharing() method..PPNote: Initialization of OpenGL rendering state etc. should be done by overriding the initializeGL() function, not 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..PPSee also setAutoBufferSwap()..SH "const QGLContext * QGLWidget::context () const"Returns the context of this widget..SH "QImage QGLWidget::convertToGLFormat ( const QImage & img ) \fC[static]\fR"Convenience function for converting a QImage into the format expected by OpenGL's texture functions..SH "bool QGLWidget::doubleBuffer () const"Returns TRUE if the contained GL rendering context has double buffering..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(), initializing first as necessary..SH "void QGLWidget::glInit () \fC[virtual protected]\fR"Initializes OpenGL for this widget's context. Calls the virtual function initializeGL()..SH "void QGLWidget::initializeGL () \fC[virtual protected]\fR"This virtual function is called one time before the first call to paintGL() or resizeGL(), and then one time whenever the widget has been assigned a new QGLContext. Reimplement it in a subclass..PPThis function should take care of setting 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(), only for the widget's overlay context instead of the widget's main context. That is, initializeOverlayGL() is called one time before the first call to paintOverlayGL() or resizeOverlayGL(). Reimplement it in a subclass..PPThis function should take care of setting 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. 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. 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 this 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, initializing first as necessary..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(), only for the widget's overlay context instead of the widget's main context. That is, 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 it..PPYou may use this method on both visible and invisible QGLWidgets..PPThis method will create a pixmap and a temporary QGLContext to render on it. Then, initializeGL(), resizeGL(), and paintGL() are called on this context. Finally, the widget's original GL context is restored..PPThe size of the pixmap will be width \fIw\fR and height \fIh.\fR If any of those are 0 (the default), 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. Use only if you know what you are doing..PPAny overlay is not rendered to the pixmap..PPBugs and limitations:.TPMay give unexpected results if the depth of the GL rendering context is different from the depth of the desktop..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. 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, int ) \fC[virtual protected]\fR"This virtual function is used in the same manner as paintGL(), only for the widget's overlay context instead of the widget's main context. That is, resizeOverlayGL() is called whenever the widget has been resized. 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"Turns on or off the automatic GL buffer swapping. If on, and the widget is using a double-buffered format, the background and foreground GL buffers will automatically be swapped after each time the paintGL() function has been called..PPThe buffer auto-swapping is on by default..PPSee also autoBufferSwap(), doubleBuffer() and swapBuffers()..SH "void QGLWidget::setMouseTracking ( bool enable ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QGLWidget::swapBuffers () \fC[virtual]\fR"Swaps the screen contents with an off-screen buffer. Works only 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. after each time 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 virtualfunction paintOverlayGL() to be executed, initializing first asnecessary..SH "SEE ALSO".BR http://doc.trolltech.com/qglwidget.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

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