使用不正确的版本

时间:2017-11-01 19:30:47

标签: c++ opengl glfw

我正在尝试使用OpenGL 3.3编译我的应用程序。我在线搜索了我的显卡,它最多支持4.4。

这是glxinfo |的回归grep OpenGL

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2) 
OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.2.3
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 17.2.3
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 17.2.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

我告诉GLFW使用主要版本3次要版本3

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

并使用核心配置文件:

glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

我很高兴指向版本3.3和核心配置文件:

python -m glad --api "gl=3.3" --generator c --out-path ./output --profile core --spec gl

但是当我打电话时

glGetString(GL_VERSION)

我回来了

3.0 Mesa 17.2.3

我不能为我的生活找出我所缺少的东西。

运行此代码的部分

{
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_FLOATING, GL_TRUE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    if (!glfwInit()) {
        std::cout << "glfw not inited" << std::endl;
    }

    glfwSetErrorCallback(error_callback);
    m_game_window = glfwCreateWindow(800, 600, "window", NULL, NULL);

    if (!m_game_window) {
        std::cout << "window creation failed" << std::endl;
        glfwTerminate();
        //crash
    }

    glfwMakeContextCurrent(m_game_window);
    gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);

    glViewport(0, 0, 800, 600);

    char *version = (char*)glGetString(GL_VERSION);
    std::cout << version;
}

1 个答案:

答案 0 :(得分:2)

您不得在glfwInit()之前调用任何GLFW函数。在您的情况下,窗口提示将由glfwInit()完全重置。