Cyc*_*ite 2 c++ eclipse opengl glut freeglut
我正在开发一个利用freeglut和 的项目GLEW。为了在我的程序中使用顶点和片段着色器,我需要使用的最低 OpenGL 版本是3.3. 我检查了OpenGL版本和GLSL版本,结果是这样的:
[cyclonite@localhost ~]$ glxinfo | grep OpenGL
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel (R) HD Graphics 620 (Kaby Lake GT2)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.3.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.3.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.3.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
Run Code Online (Sandbox Code Playgroud)
核心配置文件的 OpenGL 版本字符串和 GLSL 版本字符串都是4.5. 但是,它还显示 OpenGL 版本字符串3.0和 GLSL 版本字符串 。1.3.为了使用我自己的着色器,版本必须是3.3最低的。我尝试在着色器的开头使用#version 330 core,但是当我运行程序时出现以下错误消息:
Cannot compile vertex shader.
ERROR: Cannot compile shader.
OpenGL Version: 3.0 Mesa 17.3.3
0:4(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES
Run Code Online (Sandbox Code Playgroud)
看来该程序使用的是 OpenGL 3.0 而不是 4.5,我在网上查了一下,有人说这OpenGL 4.5 is only available if requested at context creation because compatibility contexts are not supported是在 的发行说明中Mesa,根据这篇文章。
如何在创建上下文时创建核心配置文件或请求,以便可以在程序中使用 OpenGL 4.5?
我在 Linux 操作系统上使用 Eclipse 作为我的 C++ 开发 IDE(我使用的这个特定发行版是 PCLinuxOS)。
使用glutInitContextVersion()并glutInitContextProfile()选择您想要的上下文版本和上下文配置文件:
...
glutInit( ... );
glutInitContextVersion( 3, 3 );
glutInitContextProfile( GLUT_CORE_PROFILE );
glutInitDisplayMode( ... );
glutCreateWindow( ... );
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2951 次 |
| 最近记录: |