c++linuxopenglglfw

Query highest supported OpenGL version before context initialization?


I want to know if there is a way (ideally cross platform, but if not just POSIX compliant or at least in Linux) to query for the highest supported OpenGL version in the current system.

I would like to be able to instantiate GLFW windows to be the highest supported version, rather than blindly trying different versions until one allows for valid context initialization.

EDIT:

Assume I am not creating a context. Imagine I want to replicate what glxinfo does. In other words, I want to be able to query the installed OpenGL version without EVER creating a context.


Solution

  • Have you tried to create an OpenGL context without querying for a specific version?

    When I use native OpenGL functions (glxCreateContext() or wglCreateContext()) to create a new OpenGL context, they always create a context with the highest OpenGL version supported by my graphic card (4.6).

    I don't know if GLFW have the same behavior...

    ANSWER FOR QUESTION EDIT:
    It's impossible to query any of OpenGL information WITHOUT creating a context, since you are not able to call any of glXXX() functions WITHOUT creating a context. You can instead create a dummy context (which is not shown to the user, but stay somewhere in the memory) to query all OpenGL information you want, and delete it when you are done (don't worry about it, many many software, libraries and also game engines do this, even my own).