c++ OpenGL着色版本错误- GLSL x不支持[Ubuntu 16.04]
C++ OpenGL shading version error - GLSL x is not supported [Ubuntu 16.04]
我目前正在做一个在Ubuntu 16.04上使用OpenGL的项目,并且遇到了一个主要问题。在这一点上,我不知道该怎么做,因为感觉我已经尝试了一切,以解决这个问题。
由于某些原因,我的着色器不会编译并返回以下错误:
Failed to compile vertex shader!
0:1(10): error: GLSL 4.50 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`
我已经在着色器文件中调整了版本,没有任何运气。#version 450 core
等,但我一直得到相同的结果。
作为参考,sudo 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 13.1.0-devel
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 13.1.0-devel
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 13.1.0-devel
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
glxinfo的输出显示安装了OpenGL core 4.5,那么为什么不支持呢?
我还试图找到项目中使用的OpenGL的当前版本:std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
,导致空白返回。
编辑:是否有一种方法可以强制项目/Ubuntu使用OpenGL而不是GLSL,即完全删除GLSL(这一部分)?
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 13.1.0-devel
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
对于其他遇到同样问题的人,这是我的解决方案:
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
似乎您没有明确要求核心配置文件上下文。您的glxinfo输出显示,不支持兼容性配置文件上下文(在OpenGL-3.0之前没有"兼容性"配置文件,但这是一个有争议的问题):
这告诉您在核心配置文件中支持到v4.5:
OpenGL core profile version string: 4.5 (Core Profile) Mesa 13.1.0-devel
OpenGL core profile shading language version string: 4.50
OpenGL core profile profile mask: core profile
这确实告诉你,没有明确标记core的最高版本将是OpenGL-3.0:
OpenGL version string: 3.0 Mesa 13.1.0-devel
OpenGL shading language version string: 1.30
所以要么请求一个core配置文件,要么接受你坚持使用GL-3.0及以下版本。
只是为了比较,这是一个支持OpenGL-4的OpenGL实现(NVidia)的样子。X甚至在核心配置文件之外:
OpenGL core profile version string: 4.4.0 NVIDIA 367.27
OpenGL core profile shading language version string: 4.40 NVIDIA via Cg compiler
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL version string: 4.5.0 NVIDIA 367.27
OpenGL shading language version string: 4.50 NVIDIA
如果您打算使用4.5功能,那么您需要一个核心概要文件,并且根据以下输出行
在您的系统上支持该概要文件OpenGL core profile version string: 4.5 (Core Profile) Mesa 13.1.0-devel
其他输出行
OpenGL version string: 3.0 Mesa 13.1.0-devel
并不意味着你有两个不同的openGL驱动程序,但你可以负担得起没有核心配置文件的openGL 3.0顶部。
为了使用核心配置文件功能,请确保启用它并使用正确的预处理器指令编译着色器
// Example using glut for context initialization
glutInitContextVersion(4, 5);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutInit(&argc, argv);
// Shaders
#version 450
...
尝试下一个代码在你的着色器:
"#version 320 es
精度介质浮动;
…你的代码
GLSL是OpenGL使用的着色器语言,尽管两个版本号并不总是匹配。从您的输出来看,您似乎正在使用芯片上的英特尔GPU。这个芯片的驱动程序通过Mesa来工作,据我所知,Mesa还不支持OpenGL 4。
如果你有Nvidia卡,你可以安装专有的Nvidia驱动程序,它支持最新版本的OpenGL。否则你将需要修改你的着色器来使用旧版本的语言。
- 为什么istream不支持右值提取
- 错误:(-210:不支持的格式或格式组合)功能'create'中的硬件视频解码器不支持视频源
- Casablanca/cpprestsdk listener.support接受函数,但不支持方法
- 为什么C++不支持对未初始化变量进行智能分析?
- 在 c++ 中连接字符串和整数,以便在 C++ 11 不支持计算机的情况下读取多个文件
- 在 Ubuntu 18.04 上编译 GLSL 着色器时"不支持 GLSL 3.30"?
- 为什么联机C++ IDE 不支持"graphics.h"头文件?
- Clang编译器不支持aarch64-apple-darwin上的-fxray-instrument
- 为什么我的 clang 格式不支持 PPDirectiveIndentStyle 选项?
- 为什么某些 STL 容器(堆栈、队列、优先级队列)不支持迭代器?
- 为什么不支持 Xcode 1.5?
- C++20 从括号中的值列表初始化聚合,不支持内部数组
- 为什么结构化绑定不支持可变数组?
- 您选择的 CPU 不支持 x86-64 指令集
- 将数据发送到多个客户端 UDP 时不支持地址族
- 缺少类型说明符 - 假定为 int.注意 c++ 不支持 default-int
- 瓦尔格林德"不支持arch_prctl选项"
- 错误:C4430:缺少类型说明符-假定为int.注意:C++不支持default-int
- 为什么 g++ 不支持在 Ubuntu 上使用分配器构造函数?
- c++ OpenGL着色版本错误- GLSL x不支持[Ubuntu 16.04]