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

📄 qglwidget.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 2 页
字号:
'\" t.TH QGLWidget 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQGLWidget \- Widget for rendering OpenGL graphics.SH SYNOPSIS\fC#include <qgl.h>\fR.PPInherits QWidget and QGL..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQGLWidget\fR ( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WFlags f = 0 )".br.ti -1c.BI "\fBQGLWidget\fR ( const QGLFormat & format, QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WFlags f = 0 )".br.ti -1c.BI "\fB~QGLWidget\fR ()".br.ti -1c.BI "void \fBqglColor\fR ( const QColor & c ) const".br.ti -1c.BI "void \fBqglClearColor\fR ( const QColor & c ) const".br.ti -1c.BI "bool \fBisValid\fR () const".br.ti -1c.BI "bool \fBisSharing\fR () const".br.ti -1c.BI "virtual void \fBmakeCurrent\fR ()".br.ti -1c.BI "bool \fBdoubleBuffer\fR () const".br.ti -1c.BI "virtual void \fBswapBuffers\fR ()".br.ti -1c.BI "QGLFormat \fBformat\fR () const".br.ti -1c.BI "const QGLContext * \fBcontext\fR () const".br.ti -1c.BI "virtual QPixmap \fBrenderPixmap\fR ( int w = 0, int h = 0, bool useContext = FALSE )".br.ti -1c.BI "virtual QImage \fBgrabFrameBuffer\fR ( bool withAlpha = FALSE )".br.ti -1c.BI "virtual void \fBmakeOverlayCurrent\fR ()".br.ti -1c.BI "const QGLContext * \fBoverlayContext\fR () const".br.ti -1c.BI "const QGLColormap & \fBcolormap\fR () const".br.ti -1c.BI "void \fBsetColormap\fR ( const QGLColormap & cmap )".br.ti -1c.BI "void \fBrenderText\fR ( int x, int y, const QString & str, const QFont & fnt = QFont ( ), int listBase = 2000 )".br.ti -1c.BI "void \fBrenderText\fR ( double x, double y, double z, const QString & str, const QFont & fnt = QFont ( ), int listBase = 2000 )".br.in -1c.SS "Public Slots".in +1c.ti -1c.BI "virtual void \fBupdateGL\fR ()".br.ti -1c.BI "virtual void \fBupdateOverlayGL\fR ()".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "QImage \fBconvertToGLFormat\fR ( const QImage & img )".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBinitializeGL\fR ()".br.ti -1c.BI "virtual void \fBresizeGL\fR ( int width, int height )".br.ti -1c.BI "virtual void \fBpaintGL\fR ()".br.ti -1c.BI "virtual void \fBinitializeOverlayGL\fR ()".br.ti -1c.BI "virtual void \fBresizeOverlayGL\fR ( int width, int height )".br.ti -1c.BI "virtual void \fBpaintOverlayGL\fR ()".br.ti -1c.BI "void \fBsetAutoBufferSwap\fR ( bool on )".br.ti -1c.BI "bool \fBautoBufferSwap\fR () const".br.ti -1c.BI "virtual void \fBpaintEvent\fR ( QPaintEvent * )".br.ti -1c.BI "virtual void \fBresizeEvent\fR ( QResizeEvent * )".br.ti -1c.BI "virtual void \fBglInit\fR ()".br.ti -1c.BI "virtual void \fBglDraw\fR ()".br.in -1c.SH DESCRIPTIONThe QGLWidget class is a widget for rendering OpenGL graphics..PPQGLWidget provides functionality for displaying OpenGL<sup>*</sup> graphics integrated into a Qt application. It is very simple to use. You inherit from it and use the subclass like any other QWidget, except that instead of drawing the widget's contents using QPainter etc. you use the standard OpenGL rendering commands..PPQGLWidget provides three convenient virtual functions that you can reimplement in your subclass to perform the typical OpenGL tasks:.TPpaintGL() - Renders the OpenGL scene. Gets called whenever the widget needs to be updated..TPresizeGL() - Sets up the OpenGL viewport, projection, etc. Gets called whenever the the widget has been resized (and also when it is shown for the first time because all newly created widgets get a resize event automatically)..TPinitializeGL() - Sets up the OpenGL rendering context, defines display lists, etc. Gets called once before the first time resizeGL() or paintGL() is called..PPHere is a rough outline of how a QGLWidget subclass might look:.PP.nf.br    class MyGLDrawer : public QGLWidget.br    {.br        Q_OBJECT        // must include this if you use Qt signals/slots.br.br    public:.br        MyGLDrawer( QWidget *parent, const char *name ).br            : QGLWidget(parent, name) {}.br.br    protected:.br.br        void initializeGL().br        {.br            // Set up the rendering context, define display lists etc.:.br            ....br            glClearColor( 0.0, 0.0, 0.0, 0.0 );.br            glEnable(GL_DEPTH_TEST);.br            ....br        }.br.br        void resizeGL( int w, int h ).br        {.br            // setup viewport, projection etc.:.br            glViewport( 0, 0, (GLint)w, (GLint)h );.br            ....br            glFrustum( ... );.br            ....br        }.br.br        void paintGL().br        {.br            // draw the scene:.br            ....br            glRotatef( ... );.br            glMaterialfv( ... );.br            glBegin( GL_QUADS );.br            glVertex3f( ... );.br            glVertex3f( ... );.br            ....br            glEnd();.br            ....br        }.br.br    };.br.fi.PPIf you need to trigger a repaint from places other than paintGL() (a typical example is when using timers to animate scenes), you should call the widget's updateGL() function..PPYour widget's OpenGL rendering context is made current when paintGL(), resizeGL(), or initializeGL() is called. If you need to call the standard OpenGL API functions from other places (e.g. in your widget's constructor or in your own paint functions), 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 also share OpenGL display lists between QGLWidgets (see the documentation of the QGLWidget constructors for details)..SH "Overlays"The QGLWidget creates 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()

⌨️ 快捷键说明

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