Exemple #1
0
static const gl_param_t* get_gl_param()
{
    if (!QOpenGLContext::currentContext()) {
        qWarning("%s: current context is null", __FUNCTION__);
        return gl_param_compat;
    }
    static gl_param_t* gp = 0;
    if (gp)
        return gp;
    bool has_16 = false;
    // [4] is always available
    if (test_gl_param(gl_param_desktop[4], &has_16)) {
        if (has_16 && depth16BitTexture() == 16)
            gp = (gl_param_t*)gl_param_desktop;
        else
            gp = (gl_param_t*)gl_param_desktop_fallback;
        has_16_tex = has_16;
        if (!useDeprecatedFormats()) {
            qDebug("using gl_param_desktop%s", gp == gl_param_desktop? "" : "_fallback");
            return gp;
        }
    } else if (test_gl_param(gl_param_es3[4], &has_16)) {
        gp = (gl_param_t*)gl_param_es3;
        has_16_tex = has_16;
        if (!useDeprecatedFormats()) {
            qDebug("using gl_param_es3");
            return gp;
        }
    }
    qDebug("fallback to gl_param_compat");
    gp = (gl_param_t*)gl_param_compat;
    has_16_tex = false;
    return gp;
}
Exemple #2
0
bool hasRG()
{
    static int has_rg = -1;
    if (has_rg >= 0)
        return !!has_rg;
    qDebug("check desktop rg: %#X", gl_param_desktop[1].internal_format);
    if (test_gl_param(gl_param_desktop[1])) {
        has_rg = 1;
        return true;
    }
    qDebug("check es3 rg: %#X", gl_param_es3[1].internal_format);
    if (test_gl_param(gl_param_es3[1])) {
        has_rg = 1;
        return true;
    }
    qDebug("check GL_EXT_texture_rg");
    static const char* ext[] = { "GL_EXT_texture_rg", 0}; //RED, RG, R8, RG8
    if (hasExtension(ext)) {
        qDebug("has extension GL_EXT_texture_rg");
        has_rg = 1;
        return true;
    }
    qDebug("check gl es>=3 rg");
    if (QOpenGLContext::currentContext())
        has_rg = isOpenGLES() && QOpenGLContext::currentContext()->format().majorVersion() > 2;
    return has_rg;
}
Exemple #3
0
bool hasRG()
{
    static int has_rg = -1;
    if (has_rg >= 0)
        return !!has_rg;
    if (test_gl_param(gl_param_desktop[1])) {
        has_rg = 1;
        return true;
    }
    if (test_gl_param(gl_param_es3[1])) {
        has_rg = 1;
        return true;
    }
    has_rg = 0;
    return false;
}
Exemple #4
0
static const gl_param_t* get_gl_param()
{
    if (!QOpenGLContext::currentContext()) {
        qWarning("%s: current context is null", __FUNCTION__);
        return gl_param_compat;
    }
    static gl_param_t* gp = 0;
    if (gp)
        return gp;
    bool has_16 = false;
    // [4] is always available
    if (test_gl_param(gl_param_desktop[4], &has_16)) {
        if (has_16 && depth16BitTexture() == 16)
            gp = (gl_param_t*)gl_param_desktop;
        else
            gp = (gl_param_t*)gl_param_desktop_fallback;
        has_16_tex = has_16;
        if (!useDeprecatedFormats()) {
            qDebug("using gl_param_desktop%s", gp == gl_param_desktop? "" : "_fallback");
            return gp;
        }
    } else if (test_gl_param(gl_param_es3[4], &has_16)) { //3.0 will fail because no glGetTexLevelParameteriv
        gp = (gl_param_t*)gl_param_es3;
        has_16_tex = has_16;
        if (!useDeprecatedFormats()) {
            qDebug("using gl_param_es3");
            return gp;
        }
    } else if (isOpenGLES()) {
        if (QOpenGLContext::currentContext()->format().majorVersion() > 2)
            gp = (gl_param_t*)gl_param_es3; //for 3.0
        else if (hasRG())
            gp = (gl_param_t*)gl_param_es2rg;
        has_16_tex = has_16;
        if (gp && !useDeprecatedFormats()) {
            qDebug("using gl_param_%s", gp == gl_param_es3 ? "es3" : "es2rg");
            return gp;
        }
    }
    qDebug("fallback to gl_param_compat");
    gp = (gl_param_t*)gl_param_compat;
    has_16_tex = false;
    return gp;
}