Exemple #1
0
void GLBackend::do_setStateDepthTest(State::DepthTest test) {
    if (_pipeline._stateCache.depthTest != test) {
        if (test.isEnabled()) {
            glEnable(GL_DEPTH_TEST);
            glDepthMask(test.getWriteMask());
            glDepthFunc(GL_COMPARISON_FUNCTIONS[test.getFunction()]);
        } else {
            glDisable(GL_DEPTH_TEST);
        }
        if (CHECK_GL_ERROR()) {
            qDebug() << "DepthTest" << (test.isEnabled() ? "Enabled" : "Disabled")
                    << "Mask=" << (test.getWriteMask() ? "Write" : "no Write")
                    << "Func=" << test.getFunction()
                    << "Raw=" << test.getRaw();
        }

        _pipeline._stateCache.depthTest = test;
    }
}
Exemple #2
0
void GLBackend::do_setStateDepthTest(State::DepthTest test) {
    const auto& current = _pipeline._stateCache.depthTest;
    if (current != test) {
        if (test.isEnabled()) {
            glEnable(GL_DEPTH_TEST);
        } else {
            glDisable(GL_DEPTH_TEST);
        }
        if (test.getWriteMask() != current.getWriteMask()) {
            glDepthMask(test.getWriteMask());
        }
        if (test.getFunction() != current.getFunction()) {
            glDepthFunc(COMPARISON_TO_GL[test.getFunction()]);
        }
        if (CHECK_GL_ERROR()) {
            qCDebug(gpulogging) << "DepthTest" << (test.isEnabled() ? "Enabled" : "Disabled")
                << "Mask=" << (test.getWriteMask() ? "Write" : "no Write")
                << "Func=" << test.getFunction()
                << "Raw=" << test.getRaw();
        }
        _pipeline._stateCache.depthTest = test;
    }
}