<p>According to <a href="http://www.glfw.org/docs/latest/window_guide.html#window_hints_ctx" rel="nofollow noreferrer">the GLFW docs</a>, the context version hint acts as a <em>minimum</em> version, i.e. the context you actually get may be a higher version than what you request. However, the context should be backward-compatible, so even if you get a GL 3.x context you're OK to use GL 2.x code.</p>

CC BY-SA 3.0
2017-01-21T16:39:47.863Z
2017-01-21T16:39:47.863Z
Nathan Reed
<p>This code snippet:</p>

<pre><code>GLint versionMajor;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glGetIntegerv(GLFW_CONTEXT_VERSION_MAJOR, &amp;versionMajor);
std::cout &lt;&lt; "Version major:" &lt;&lt; version &lt;&lt; std::endl;
</code></pre>

<p>prints "3" in my screen, but in the first line I set the the GLFW_CONTEXT_VERSION_MAJOR to "2". How I can get back that value?</p>

CC BY-SA 3.0
2017-01-21T18:43:27.343Z
`glGetIntegerv(GLFW_CONTEXT_VERSION_MAJOR` I'm pretty sure that doesn't work. OpenGL doesn't know what to do with `GLFW_CONTEXT_VERSION_MAJOR`.
Nicol Bolas
<opengl><c++>
How to get the GLFW_CONTEXT_VERSION_MAJOR value?
Adrian
# How to get the GLFW_CONTEXT_VERSION_MAJOR value?

(Asked by: username_0 on 2017-01-21)

This code snippet:

```
GLint versionMajor;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glGetIntegerv(GLFW_CONTEXT_VERSION_MAJOR, &versionMajor);
std::cout << "Version major:" << version << std::endl;

```

prints "3" in my screen, but in the first line I set the the GLFW\_CONTEXT\_VERSION\_MAJOR to "2". How I can get back that value?

**Tags:** opengl, c++

> **Comments:**
> **username_1**: `glGetIntegerv(GLFW_CONTEXT_VERSION_MAJOR` I'm pretty sure that doesn't work. OpenGL doesn't know what to do with `GLFW_CONTEXT_VERSION_MAJOR`.  

---

## 1 answers

### Answer by username_2 on 2017-01-21. Score: 4 | Accepted answer

According to [the GLFW docs](http://www.glfw.org/docs/latest/window_guide.html#window_hints_ctx), the context version hint acts as a *minimum* version, i.e. the context you actually get may be a higher version than what you request. However, the context should be backward-compatible, so even if you get a GL 3.x context you're OK to use GL 2.x code.


---

