How can I find out which version of opengl is supported by my system?

Take a look at this very simple C ++ code:

if(!glfwInit())
{
    return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

window = glfwCreateWindow(640, 480, "Test", NULL, NULL);
if (window==NULL)
{
    return -1;
}
glfwMakeContextCurrent(window);

std::cout << "GL_VERSION: " << glGetString(GL_VERSION) << std::endl;

I don’t understand how I can “detect” the max opengl version that I can install in the lines:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

This line cannot be placed before glfwMakeContextCurrent:

glGetString(GL_VERSION)

So my question is how can I determine the opengl versions that my system supports at the beginning of the program.

thank

+4
source share
2 answers

See the GLFW guid for window creation tips that clearly state:

GLFW_CONTEXT_VERSION_MAJOR GLFW_CONTEXT_VERSION_MINOR API, . API.

OpenGL: GLFW_CONTEXT_VERSION_MAJOR GLFW_CONTEXT_VERSION_MINOR , , OpenGL . 1.0 , - 3.0 , .

, GLFW , 1.0, .


, OpenGL, glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, ) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, ).

, , , glGetString(GL_VERSION).

OpenGL, GLFW:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, required_major);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, required_minor);

glfwCreateWindow , .


, opengl ?

:

OpenGL, glGetString(GL_VERSION).


, .

, :

glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+1

, GL . GL ( ), , , .

, - .

- , , , , , . , - , .

, , - "" GL, , , - GLFW. GLFW . API GL. GLFW, @Rabbid76, GL ( 2.1 OSX 3.0 mesa/linux). , - GL .

, , , , , 5.something, GL 4.6, , , , x for 4.x , , 5.0 .

+3

Source: https://habr.com/ru/post/1686716/


All Articles