使用GLUT / FreeGLUT创建核心上下文?

问题描述 投票:1回答:1

我正在开发一个利用freeglutGLEW的项目。为了在我的程序中使用顶点和片段着色器,我需要使用的最小OpenGL版本是3.3。我检查了OpenGL版本和GLSL版本,结果是this

[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:

OpenGL版本字符串以及核心配置文件的GLSL版本字符串都是4.5。但是,它还显示OpenGL版本字符串是3.0而GLSL版本字符串是1.3.为了使用我自己的着色器,版本必须是3.3最小值。我试着在着色器的开头使用#version 330 core但是当我运行我的程序时,出现以下error message

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 

根据OpenGL 4.5 is only available if requested at context creation because compatibility contexts are not supported的说法,该程序似乎使用的是OpenGL 3.0而不是4.5,我已经在线查询,有人说Mesathis post的发行说明中。

如何在创建上下文时创建核心配置文件或请求,以便在程序中使用OpenGL 4.5?

我在Linux操作系统上使用Eclipse作为我的C ++开发IDE(我使用的这个特定发行版是PCLinuxOS)。

c++ eclipse opengl glut freeglut
1个回答
3
投票

使用glutInitContextVersion()glutInitContextProfile()选择所需的上下文版本和上下文配置文件:

...
glutInit( ... );
glutInitContextVersion( 3, 3 );
glutInitContextProfile( GLUT_CORE_PROFILE );
glutInitDisplayMode( ... );
glutCreateWindow( ... );
...

Documentation? What documentation?

© www.soinside.com 2019 - 2024. All rights reserved.