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

📄 qgl.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}/*! \overload    Generates and binds a 2D GL texture based on \a pixmap.*/GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint format){    Q_D(QGLContext);    return d->bindTexture(pixmap, target, format, false);}/*!    Removes the texture identified by \a id from the texture cache. If    the context is not shared by any other QGLContext,    glDeleteTextures() will be called to delete the texture from the    context.    \sa bindTexture()*/void QGLContext::deleteTexture(GLuint id){    if (!qt_tex_cache)        return;    QList<QString> keys = qt_tex_cache->keys();    for (int i = 0; i < keys.size(); ++i) {        QGLTexture *tex = qt_tex_cache->object(keys.at(i));        if (tex->id == id && tex->context == this) {            qt_tex_cache->remove(keys.at(i));            break;        }    }}/*!    This function sets the limit for the texture cache to \a size,    expressed in kilobytes.    By default, the cache limit is approximately 64 MB.    \sa textureCacheLimit()*/void QGLContext::setTextureCacheLimit(int size){    qt_tex_cache_limit = size;    if (qt_tex_cache)        qt_tex_cache->setMaxCost(qt_tex_cache_limit);}/*!    Returns the current texture cache limit in kilobytes.    \sa setTextureCacheLimit()*/int QGLContext::textureCacheLimit(){    return qt_tex_cache_limit;}/*!    \fn QGLFormat QGLContext::format() const    Returns the frame buffer format that was obtained (this may be a    subset of what was requested).    \sa requestedFormat()*//*!    \fn QGLFormat QGLContext::requestedFormat() const    Returns the frame buffer format that was originally requested in    the constructor or setFormat().    \sa format()*//*!    Sets a \a format for this context. The context is \link reset()    reset\endlink.    Call create() to create a new GL context that tries to match the    new format.    \code    QGLContext *cx;    //  ...    QGLFormat f;    f.setStereo(true);    cx->setFormat(f);    if (!cx->create())        exit(); // no OpenGL support, or cannot render on the specified paintdevice    if (!cx->format().stereo())        exit(); // could not create stereo context    \endcode    \sa format(), reset(), create()*/void QGLContext::setFormat(const QGLFormat &format){    Q_D(QGLContext);    reset();    d->glFormat = d->reqFormat = format;}/*!    \internal*/void QGLContext::setDevice(QPaintDevice *pDev){    Q_D(QGLContext);    if (isValid())        reset();    d->paintDevice = pDev;    if (d->paintDevice && (d->paintDevice->devType() != QInternal::Widget                           && d->paintDevice->devType() != QInternal::Pixmap                           && d->paintDevice->devType() != QInternal::Pbuffer)) {        qWarning("QGLContext: Unsupported paint device type");    }}/*!    \fn bool QGLContext::isValid() const    Returns true if a GL rendering context has been successfully    created; otherwise returns false.*//*!    \fn void QGLContext::setValid(bool valid)    \internal    Forces the GL rendering context to be valid.*//*!    \fn bool QGLContext::isSharing() const    Returns true if this context is sharing its GL context with    another QGLContext, otherwise false is returned. Note that context    sharing might not be supported between contexts with different    formats.*//*!    \fn bool QGLContext::deviceIsPixmap() const    Returns true if the paint device of this context is a pixmap;    otherwise returns false.*//*!    \fn bool QGLContext::windowCreated() const    Returns true if a window has been created for this context;    otherwise returns false.    \sa setWindowCreated()*//*!    \fn void QGLContext::setWindowCreated(bool on)    If \a on is true the context has had a window created for it. If    \a on is false no window has been created for the context.    \sa windowCreated()*//*!    \fn uint QGLContext::colorIndex(const QColor& c) const    \internal    Returns a colormap index for the color c, in ColorIndex mode. Used    by qglColor() and qglClearColor().*//*!    \fn bool QGLContext::initialized() const    Returns true if this context has been initialized, i.e. if    QGLWidget::initializeGL() has been performed on it; otherwise    returns false.    \sa setInitialized()*//*!    \fn void QGLContext::setInitialized(bool on)    If \a on is true the context has been initialized, i.e.    QGLContext::setInitialized() has been called on it. If \a on is    false the context has not been initialized.    \sa initialized()*//*!    \fn const QGLContext* QGLContext::currentContext()    Returns the current context, i.e. the context to which any OpenGL    commands will currently be directed. Returns 0 if no context is    current.    \sa makeCurrent()*//*!    \fn QColor QGLContext::overlayTransparentColor() const    If this context is a valid context in an overlay plane, returns    the plane's transparent color. Otherwise returns an \link    QColor::isValid() invalid \endlink color.    The returned color's \link QColor::pixel() pixel \endlink value is    the index of the transparent color in the colormap of the overlay    plane. (Naturally, the color's RGB values are meaningless.)    The returned QColor object will generally work as expected only    when passed as the argument to QGLWidget::qglColor() or    QGLWidget::qglClearColor(). Under certain circumstances it can    also be used to draw transparent graphics with a QPainter. See the    examples/opengl/overlay_x11 example for details.*//*!    Creates the GL context. Returns true if it was successful in    creating a valid GL rendering context on the paint device    specified in the constructor; otherwise returns false (i.e. the    context is invalid).    After successful creation, format() returns the set of features of    the created GL rendering context.    If \a shareContext points to a valid QGLContext, this method will    try to establish OpenGL display list and texture object sharing    between this context and the \a shareContext. Note that this may    fail if the two contexts have different \l {format()} {formats}.    Use isSharing() to see if sharing is in effect.    \warning Implementation note: initialization of C++ class    members usually takes place in the class constructor. QGLContext    is an exception because it must be simple to customize. The    virtual functions chooseContext() (and chooseVisual() for X11) can    be reimplemented in a subclass to select a particular context. The    problem is that virtual functions are not properly called during    construction (even though this is correct C++) because C++    constructs class hierarchies from the bottom up. For this reason    we need a create() function.    \sa chooseContext(), format(), isValid()*/bool QGLContext::create(const QGLContext* shareContext){    Q_D(QGLContext);    reset();    d->valid = chooseContext(shareContext);    if (d->sharing)  // ok, we managed to share        qgl_share_reg()->addShare(this, shareContext);    return d->valid;}bool QGLContext::isValid() const{    Q_D(const QGLContext);    return d->valid;}void QGLContext::setValid(bool valid){    Q_D(QGLContext);    d->valid = valid;}bool QGLContext::isSharing() const{    Q_D(const QGLContext);    return d->sharing;}QGLFormat QGLContext::format() const{    Q_D(const QGLContext);    return d->glFormat;}QGLFormat QGLContext::requestedFormat() const{    Q_D(const QGLContext);    return d->reqFormat;} QPaintDevice* QGLContext::device() const{    Q_D(const QGLContext);    return d->paintDevice;}bool QGLContext::deviceIsPixmap() const{    Q_D(const QGLContext);    return d->paintDevice->devType() == QInternal::Pixmap;}bool QGLContext::windowCreated() const{    Q_D(const QGLContext);    return d->crWin;}void QGLContext::setWindowCreated(bool on){    Q_D(QGLContext);    d->crWin = on;}bool QGLContext::initialized() const{    Q_D(const QGLContext);    return d->initDone;}void QGLContext::setInitialized(bool on){    Q_D(QGLContext);    d->initDone = on;}const QGLContext* QGLContext::currentContext(){    if (qgl_context_storage.hasLocalData())        return qgl_context_storage.localData()->context;    return 0;}/*!    \fn bool QGLContext::chooseContext(const QGLContext* shareContext = 0)    This semi-internal function is called by create(). It creates a    system-dependent OpenGL handle that matches the format() of \a    shareContext as closely as possible, returning true if successful    or false if a suitable handle could not be found.    On Windows, it calls the virtual function choosePixelFormat(),    which finds a matching pixel format identifier. On X11, it calls    the virtual function chooseVisual() which finds an appropriate X    visual. On other platforms it may work differently.*//*!    \fn void QGLContext::reset()    Resets the context and makes it invalid.    \sa create(), isValid()*//*!    \fn void QGLContext::makeCurrent()    Makes this context the current OpenGL rendering context. All GL    functions you call operate on this context until another context    is made current.    In some very rare cases the underlying call may fail. If this    occurs an error message is output to stderr.*//*!    \fn void QGLContext::swapBuffers() const    Swaps the screen contents with an off-screen buffer. Only works if    the context is in double buffer mode.    \sa QGLFormat::setDoubleBuffer()*//*!    \fn void QGLContext::doneCurrent()    Makes no GL context the current context. Normally, you do not need    to call this function; QGLContext calls it as necessary.*//*!    \fn QPaintDevice* QGLContext::device() const    Returns the paint device set for this context.    \sa QGLContext::QGLContext()*//*!    \obsolete    \fn void QGLContext::generateFontDisplayLists(const QFont& font, int listBase)    Generates a set of 256 display lists for the 256 first characters    in the font \a font. The first list will start at index \a listBase.    \sa QGLWidget::renderText()*//*****************************************************************************  QGLWidget implementation *****************************************************************************//*!    \class QGLWidget    \brief The QGLWidget class is a widget for rendering OpenGL graphics.    \ingroup multimedia    \mainclass    QGLWidget provides functionality for displaying OpenGL 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 you have the choice between using QPainter and    standard OpenGL rendering commands.    QGLWidget provides three convenient virtual functions that you can    reimplement in your subclass to perform the typical OpenGL tasks:    \list    \i paintGL() - Renders the OpenGL scene. Gets called whenever the widget    needs to be updated.    \i resizeGL() - 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).    \i initializeGL() - Sets up the OpenGL rendering context, defines display    lists, etc. Gets called once before the first time resizeGL() or    paintGL() is called.    \endlist    Here is a rough outline of how a QGLWidget subclass might look:    \code    class MyGLDrawer : public QGLWidget    {        Q_OBJECT        // must include this if you use Qt signals/slots    public:        MyGLDrawer(QWidget *parent)            : QGLWidget(

⌨️ 快捷键说明

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