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

📄 qgl.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}/*!    Set the preferred stencil buffer size to \a size.    \sa stencilBufferSize(), setStencil(), stencil()*/void QGLFormat::setStencilBufferSize(int size){    if (size < 0) {        qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);        return;    }    d->stencilSize = size;}/*!    Returns the stencil buffer size.    \sa stencil(), setStencil(), setStencilBufferSize()*/int QGLFormat::stencilBufferSize() const{   return d->stencilSize;}/*!    \fn bool QGLFormat::hasOpenGL()    Returns true if the window system has any OpenGL support;    otherwise returns false.    \warning This function must not be called until the QApplication    object has been created.*//*!    \fn bool QGLFormat::hasOpenGLOverlays()    Returns true if the window system supports OpenGL overlays;    otherwise returns false.    \warning This function must not be called until the QApplication    object has been created.*/QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(const QString &versionString){    QGLFormat::OpenGLVersionFlags versionFlags = QGLFormat::OpenGL_Version_None;    if (versionString.startsWith(QLatin1String("OpenGL ES"))) {        QStringList parts = versionString.split(QLatin1Char(' '));        if (parts.size() >= 3) {            if (parts[2].startsWith(QLatin1String("1."))) {                if (parts[1].endsWith(QLatin1String("-CM"))) {                    versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_0 |                                    QGLFormat::OpenGL_ES_CommonLite_Version_1_0;                    if (parts[2].startsWith(QLatin1String("1.1")))                        versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_1 |                                        QGLFormat::OpenGL_ES_CommonLite_Version_1_1;                }                else {                    // Not -CM, must be CL, CommonLite                    versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_0;                    if (parts[2].startsWith(QLatin1String("1.1")))                        versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_1;                }            }            else {                // OpenGL ES version 2.0 or higher                versionFlags |= QGLFormat::OpenGL_ES_Version_2_0;            }        }        else {            // if < 3 parts to the name, it is an unrecognised OpenGL ES            qWarning("Unrecognised OpenGL ES version");        }    }    else {        // not ES, regular OpenGL, the version numbers are first in the string        if (versionString.startsWith(QLatin1String("1."))) {            switch (versionString[2].toAscii()) {            case '5':                versionFlags |= QGLFormat::OpenGL_Version_1_5;            case '4':                versionFlags |= QGLFormat::OpenGL_Version_1_4;            case '3':                versionFlags |= QGLFormat::OpenGL_Version_1_3;            case '2':                versionFlags |= QGLFormat::OpenGL_Version_1_2;            case '1':                versionFlags |= QGLFormat::OpenGL_Version_1_1;            default:                break;            }        }        else if (versionString.startsWith(QLatin1String("2."))) {            versionFlags |= QGLFormat::OpenGL_Version_1_1 |                            QGLFormat::OpenGL_Version_1_2 |                            QGLFormat::OpenGL_Version_1_3 |                            QGLFormat::OpenGL_Version_1_4 |                            QGLFormat::OpenGL_Version_1_5 |                            QGLFormat::OpenGL_Version_2_0;            QString minorVersion = versionString.section(QLatin1Char(' '), 0, 0).section(QLatin1Char('.'), 1, 1);            if (minorVersion == QChar(QLatin1Char('1')))                versionFlags |= QGLFormat::OpenGL_Version_2_1;        }        else            qWarning("Unrecognised OpenGL version");    }    return versionFlags;}/*!    \enum QGLFormat::OpenGLVersionFlag    \since 4.2    This enum describes the various OpenGL versions that are    recognized by Qt. Use the QGLFormat::openGLVersionFlags() function    to identify which versions that are supported at runtime.    \value OpenGL_Version_None  If no OpenGL is present or if no OpenGL context is current.    \value OpenGL_Version_1_1  OpenGL version 1.1 or higher is present.    \value OpenGL_Version_1_2  OpenGL version 1.2 or higher is present.    \value OpenGL_Version_1_3  OpenGL version 1.3 or higher is present.    \value OpenGL_Version_1_4  OpenGL version 1.4 or higher is present.    \value OpenGL_Version_1_5  OpenGL version 1.5 or higher is present.    \value OpenGL_Version_2_0  OpenGL version 2.0 or higher is present.    Note that version 2.0 supports all the functionality of version 1.5.    \value OpenGL_Version_2_1  OpenGL version 2.1 or higher is present.    \value OpenGL_ES_CommonLite_Version_1_0  OpenGL ES version 1.0 Common Lite or higher is present.    \value OpenGL_ES_Common_Version_1_0  OpenGL ES version 1.0 Common or higher is present.    The Common profile supports all the features of Common Lite.    \value OpenGL_ES_CommonLite_Version_1_1  OpenGL ES version 1.1 Common Lite or higher is present.    \value OpenGL_ES_Common_Version_1_1  OpenGL ES version 1.1 Common or higher is present.    The Common profile supports all the features of Common Lite.    \value OpenGL_ES_Version_2_0  OpenGL ES version 2.0 or higher is present.    Note that OpenGL ES version 2.0 does not support all the features of OpenGL ES 1.x.    So if OpenGL_ES_Version_2_0 is returned, none of the ES 1.x flags are returned.    See also \l{http://www.opengl.org} for more information about the different    revisions of OpenGL.    \sa openGLVersionFlags()*//*!    \since 4.2    Identifies, at runtime, which OpenGL versions that are supported    by the current platform.    Note that if OpenGL version 1.5 is supported, its predecessors    (i.e., version 1.4 and lower) are also supported. To identify the    support of a particular feature, like multi texturing, test for    the version in which the feature was first introduced (i.e.,    version 1.3 in the case of multi texturing) to adapt to the largest    possible group of runtime platforms.    This function needs a valid current OpenGL context to work;    otherwise it will return OpenGL_Version_None.    \sa hasOpenGL(), hasOpenGLOverlays()*/QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags(){    static bool firstTime=true;    static OpenGLVersionFlags versionFlags = OpenGL_Version_None;    if (!firstTime)        return versionFlags;    if (!hasOpenGL())        return OpenGL_Version_None;    if (firstTime) {        firstTime = false;        QGLWidget *dummy = 0;        if (QGLContext::currentContext() == 0) {            dummy = new QGLWidget;            dummy->makeCurrent(); // glGetString() needs a current context        }        QString versionString(QLatin1String(reinterpret_cast<const char*>(glGetString(GL_VERSION))));        versionFlags = qOpenGLVersionFlagsFromString(versionString);        if (dummy)            delete dummy;    }    return versionFlags;}/*!    Returns the default QGLFormat for the application. All QGLWidgets    that are created use this format unless another format is    specified, e.g. when they are constructed.    If no special default format has been set using    setDefaultFormat(), the default format is the same as that created    with QGLFormat().    \sa setDefaultFormat()*/QGLFormat QGLFormat::defaultFormat(){    return *qgl_default_format();}/*!    Sets a new default QGLFormat for the application to \a f. For    example, to set single buffering as the default instead of double    buffering, your main() might contain code like this:    \code    QApplication a(argc, argv);    QGLFormat f;    f.setDoubleBuffer(false);    QGLFormat::setDefaultFormat(f);    \endcode    \sa defaultFormat()*/void QGLFormat::setDefaultFormat(const QGLFormat &f){    *qgl_default_format() = f;}/*!    Returns the default QGLFormat for overlay contexts.    The factory default overlay format is:    \list    \i \link setDoubleBuffer() Double buffer:\endlink Disabled.    \i \link setDepth() Depth buffer:\endlink Disabled.    \i \link setRgba() RGBA:\endlink Disabled (i.e., color index enabled).    \i \link setAlpha() Alpha channel:\endlink Disabled.    \i \link setAccum() Accumulator buffer:\endlink Disabled.    \i \link setStencil() Stencil buffer:\endlink Disabled.    \i \link setStereo() Stereo:\endlink Disabled.    \i \link setDirectRendering() Direct rendering:\endlink Enabled.    \i \link setOverlay() Overlay:\endlink Disabled.    \i \link setPlane() Plane:\endlink 1 (i.e., first overlay plane).    \endlist    \sa setDefaultFormat()*/QGLFormat QGLFormat::defaultOverlayFormat(){    return *defaultOverlayFormatInstance();}/*!    Sets a new default QGLFormat for overlay contexts to \a f. This    format is used whenever a QGLWidget is created with a format that    hasOverlay() enabled.    For example, to get a double buffered overlay context (if    available), use code like this:    \code    QGLFormat f = QGLFormat::defaultOverlayFormat();    f.setDoubleBuffer(true);    QGLFormat::setDefaultOverlayFormat(f);    \endcode    As usual, you can find out after widget creation whether the    underlying OpenGL system was able to provide the requested    specification:    \code    // ...continued from above    MyGLWidget* myWidget = new MyGLWidget(QGLFormat(QGL::HasOverlay), ...);    if (myWidget->format().hasOverlay()) {        // Yes, we got an overlay, let's check _its_ format:        QGLContext* olContext = myWidget->overlayContext();        if (olContext->format().doubleBuffer())            ; // yes, we got a double buffered overlay        else            ; // no, only single buffered overlays are available    }    \endcode    \sa defaultOverlayFormat()*/void QGLFormat::setDefaultOverlayFormat(const QGLFormat &f){    QGLFormat *defaultFormat = defaultOverlayFormatInstance();    *defaultFormat = f;    // Make sure the user doesn't request that the overlays themselves    // have overlays, since it is unlikely that the system supports    // infinitely many planes...    defaultFormat->setOverlay(false);}/*!    Returns true if all the options of the two QGLFormats are equal;    otherwise returns false.*/bool operator==(const QGLFormat& a, const QGLFormat& b){    return (int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize        && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize        && a.d->depthSize == b.d->depthSize;}/*!    Returns false if all the options of the two QGLFormats are equal;    otherwise returns true.*/bool operator!=(const QGLFormat& a, const QGLFormat& b){    return !(a == b);}/*****************************************************************************  QGLContext implementation *****************************************************************************/void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format){    Q_Q(QGLContext);    glFormat = reqFormat = format;    valid = false;    q->setDevice(dev);#if defined(Q_WS_X11)    pbuf = 0;    gpm = 0;    screen = QX11Info::appScreen();#endif#if defined(Q_WS_WIN)    dc = 0;    win = 0;    pixelFormatId = 0;    cmap = 0;    hbitmap = 0;    hbitmap_hdc = 0;#endif#if defined(Q_WS_MAC)    update = false;    vi = 0;#endif#if defined(Q_WS_QWS)    dpy = 0;    cx = 0;    config = 0;    surface = 0;#endif    crWin = false;    initDone = false;    sharing = false;    clear_on_painter_begin = true;}QGLContext* QGLContext::currentCtx = 0;// returns the highest number closest to v, which is a power of 2// NB! assumes 32 bit intsint qt_next_power_of_two(int v){    v--;    v |= v >> 1;    v |= v >> 2;    v |= v >> 4;    v |= v >> 8;    v |= v >> 16;    ++v;    return v;}class QGLTexture {public:    QGLTexture(const QGLContext *ctx, GLuint tx_id, qint64 _qt_id, bool _clean = false)        : context(ctx), id(tx_id), qt_id(_qt_id), clean(_clean) {}    ~QGLTexture() {        if (clean || !context->isSharing()) {            QGLContext *current = const_cast<QGLContext *>(QGLContext::currentContext());            QGLContext *ctx = const_cast<QGLContext *>(context);            bool switch_context = current && current != ctx;            if (switch_context)                ctx->makeCurrent();            glDeleteTextures(1, &id);            if (switch_context)                current->makeCurrent();        }     }    const QGLContext *context;    GLuint id;    qint64 qt_id;    bool clean;};typedef QCache<QString, QGLTexture> QGLTextureCache;static int qt_tex_cache_limit = 64*1024; // cache ~64 MB worth of textures - this is not accurate thoughstatic QGLTextureCache *qt_tex_cache = 0;typedef void (*_qt_pixmap_cleanup_hook_64)(qint64);typedef void (*_qt_image_cleanup_hook_64)(qint64);extern Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64;extern Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64;// DDS format structurestruct DDSFormat {    quint32 dwSize;    quint32 dwFlags;    quint32 dwHeight;    quint32 dwWidth;    quint32 dwLinearSize;    quint32 dummy1;    quint32 dwMipMapCount;    quint32 dummy2[11];    struct {        quint32 dummy3[2];        quint32 dwFourCC;        quint32 dummy4[5];    } ddsPixelFormat;};// compressed texture pixel formats#define FOURCC_DXT1  0x31545844#define FOURCC_DXT2  0x32545844#define FOURCC_DXT3  0x33545844#define FOURCC_DXT4  0x34545844#define FOURCC_DXT5  0x35545844#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT  0x83F1#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT  0x83F2#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT  0x83F3#endif#ifndef GL_GENERATE_MIPMAP_SGIS#define GL_GENERATE_MIPMAP_SGIS       0x8191#define GL_GENERATE_MIPMAP_HINT_SGIS  0x8192#endif

⌨️ 快捷键说明

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