OpenGL display lists (deprecated but supported) how to tell if supported?

365 Views Asked by At

I've read that in OpenGL v3 display lists are deprecated, though some manufacturers will support them for the forseeable future.

Is there an OpenGL get... function which tells me explicitly if display lists are supported in the driver I'm interrogating?

2

There are 2 best solutions below

2
Luca On BEST ANSWER

Call glGetString with GL_VERSION. If the version is equal or lower than 2.1, display lists are surely supported. In the case the version is greater, it depends if you have requested an OpenGL CORE profile or an OpenGL COMPATIBILITY profile.

To simplify, if you create a context with wglCreateContext (or equalivalent on other platforms), you are creating a compatibility profile. You should also check support for GL_ARB_compatibility calling glGetString with GL_EXTENSIONS.

0
Reto Koradi On

If you're using at least OpenGL 3.0, you can query all the details with glGetIntegerv(). If you deal with even older version, you'll have to check glGetString(GL_VERSION) first. If that's below 3.0, you're done (with display lists supported). Otherwise, proceed with the checks below.

In 3.0 and higher, you can also get the current version with:

GLint majVers = 0, minVers = 0;
glGetIntegerv(GL_MAJOR_VERSION, &majVers);
glGetIntegerv(GL_MINOR_VERSION, &minVers);

While the Core Profile was only introduced in 3.2, display lists were already marked as deprecated with 3.0. A "forward compatible" flag was introduced at that time. So in theory, you could have a 3.0 implementation without support for display lists. Then, starting in 3.2, anything using the core profile will obviously not have display lists.

This is untested, but I believe the correct logic to test this would look like this:

bool hasDisplayLists = true;
if (strcmp(glGetString(GL_VERSION), "3") > 0) {
    // Check for forward-compatible flag in 3.0 and higher.
    GLint ctxFlags = 0;
    glGetIntegerv(GL_CONTEXT_FLAGS, &ctxFlags);
    if (ctxFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) {
        hasDisplayLists = false;
    } else {
        GLint majVers = 0, minVers = 0;
        glGetIntegerv(GL_MAJOR_VERSION, &majVers);
        glGetIntegerv(GL_MINOR_VERSION, &minVers);
        // Check for core profile in 3.2 and higher.
        if (majVers > 3 || minVers >= 2) {
            GLint profMask = 0;
            glGetIntegerv(GL_CONTEXT_PROFILE_MASK, profMask);
            if (profMask & GL_CONTEXT_CORE_PROFILE_BIT) {
                hasDisplayLists = false;
            }
        }
    }
}