1
\$\begingroup\$

Typical GLFW applications have these lines after glfwInit():

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

And similarly:

glfwMakeContextCurrent(window);

I get that glfwMakeContextCurrent is needed before sending calls to the OpenGL API, but the doc says

You can require a minimum OpenGL version by setting the GLFW_CONTEXT_VERSION_MAJOR and GLFW_CONTEXT_VERSION_MINOR hints before creation

But why would I want that? Why would I cut options for OpenGL versions? I did not understand that, if I am interpreting it correctly in the first place

\$\endgroup\$
0
1
\$\begingroup\$

Like many others, OpenGL is an evolving software. As time goes by, it needs to adapt to users needs and to the new and evolving hardware that the manufacturers such as Nvidia come up with.

As OpenGL version goes up, new features are offered, since sometimes those features require a more recent hardware, not every user can benefit from them. So this means that a shiny new thing you can do with OpenGL and show your players in your game will not be available for the users using older hardware.

By setting the minimal version of OpenGL, you're telling the API that you'll probably use more recent features, and it will help tell whether the user can run your game or not. It will also prevent the use of some older, deprecated features.

One of the side effects I can think of, is that software like NVIDIA Nsight will support calls only for the most recent OpenGL versions. So if you decide to build your game supporting an older OpenGL minimal version (because you want to support more users), you'll not be able that kind of tool to debug your code.

From what I understand, studios that have more resources will implement the same feature in a similar way using multiple OpenGL version, where the "more recent" way will be more beautiful and/or run faster.

\$\endgroup\$
0
0
\$\begingroup\$

You want to set a minimum version to have a functionality of that version available. That includes functionality of the shading language of the respective version.

Examples:

  1. Set 4.0 to have tessellation in the shader pipeline
  2. Set 4.2 to have a debug context
  3. Set 4.5 to have DSA (Direct State Access) available

... and so on.

See also: https://www.khronos.org/opengl/wiki/OpenGL_Context and https://www.glfw.org/docs/latest/context_guide.html

The latest version, 4.6, was defined in 2017. Setting a minimum versions may give the driver opportunities to optimise and to not reserve resources for functionality that will not be used, but that's speculative from my side.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy