尽管 glxinfo 断言可用,但 OpenGL 核心配置文件不可用

OpenGL core profile not available despite glxinfo asserting is available

我正在 运行ning:FreeBSD 12.2-RELEASE,我有一台 ThinkPad x230,我认为它有一个 Intel HD 4000 GPU。我正在尝试使用核心配置文件 运行 GLSL 4.20。当我 运行 我的程序(用 C 编写)时,我得到:

Error - 0:1(10): error: GLSL 4.20 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

但是,如果我 运行 glxinfo 命令,我会得到(除其他信息外)这个:

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile 
OpenGL core profile version string: 4.2 (Core Profile) Mesa 19.0.8
OpenGL core profile shading language version string: 4.20
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
    GL_3DFX_texture_compression_FXT1, GL_AMD_conservative_depth, 
    GL_AMD_draw_buffers_blend, GL_AMD_multi_draw_indirect, 
    GL_AMD_seamless_cubemap_per_texture, GL_AMD_shader_trinary_minmax, 
    GL_AMD_texture_texture4, GL_AMD_vertex_shader_layer, 
    GL_AMD_vertex_shader_viewport_index, GL_ANGLE_texture_compression_dxt3, 
    GL_ANGLE_texture_compression_dxt5, GL_APPLE_object_purgeable, 
    GL_ARB_ES2_compatibility, GL_ARB_ES3_compatibility,
    ...

我已经删减了上面的输出,因为它非常长。此外,此维基百科 link 还断言 GPU 确实支持 OpenGL 4.20(尽管它仅指 GNU/Linux 和 Windows 平台)。所以我真的很困惑我的系统是否支持 OpenGL 4.20。我是不是遗漏了什么或者 glxinfo 不准确?

另外当我 运行 glxgears -info 我得到(完整输出也被修剪):

Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
GL_RENDERER   = Mesa DRI Intel(R) Ivybridge Mobile 
GL_VERSION    = 3.0 Mesa 19.0.8
GL_VENDOR     = Intel Open Source Technology Center
...

然后如果我在我的顶点和片段着色器中设置 #version 300 core,同样的错误会弹出:

Error - 0:1(10): error: GLSL 3.00 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

当我在程序中编译我的着色器时弹出这个错误。我通过 GLFW3 使用 OpenGL,GLAD 设置为 OpenGL 版本 4.20,核心配置文件来自 here。任何建议都非常受欢迎。

我正在编辑我的问题,添加我正在 运行ning:

的初始化代码
struct GameContext* new_game_context(size_t width, size_t height) {
    printf("[GameContext] new_game_context.\n");
    struct GameContext* game_context = calloc(1, sizeof(struct GameContext));

    abort_on(&null_pointer, (void*) game_context, GAME_CONTEXT_INSUFFICIENT_MEMORY);

    game_context->keyboard = new_keyboard();
    game_context->window = 0;
    game_context->quit_game = false;

    glfwInit();
    glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);

    game_context->window = glfwCreateWindow(width, height, "Test", 0, 0);

    abort_on(&null_pointer, (void*) game_context->window, GAME_CONTEXT_GLFW_WINDOW_ERROR);

    glfwMakeContextCurrent(game_context->window);

    if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress))
        abort_on(&always, NULL, GAME_CONTEXT_GLAD_ERROR);

    glfwSwapInterval(1);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glEnable(GL_LINE_SMOOTH);
    glLineWidth(GAME_CONTEXT_LINE_WIDTH);
    glfwSetKeyCallback(game_context->window, (GLFWkeyfun) handle_keyboard_event);
    glfwSetWindowUserPointer(game_context->window, (void*) game_context->keyboard);

    game_context->game_objects = create_game_objects();

    return game_context;
}

Mesa 通常会为您提供 GL 2.1 或 3.0 环境,除非您要求更高。

glfwCreateWindow()之前使用glfwWindowHint()设置GL版本和Core-ness要求:

glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 2 );
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );