[英]0:1(10): error: GLSL 3.30 is not supported. ubuntu 18.04 c++
[英]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"
的輸出 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核心4.5,為什么不支持這個?
我還試圖找到項目中使用的當前版本的OpenGL: std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
這導致空白回報。
到目前為止,我已經在這個問題上花了10個小時,所以任何幫助都表示贊賞!
編輯:有沒有辦法迫使項目/ 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
...這確實告訴你,未明確標記為核心的最高版本將是OpenGL-3.0:
OpenGL version string: 3.0 Mesa 13.1.0-devel
OpenGL shading language version string: 1.30
因此要么請求核心配置文件,要么接受您堅持使用GL-3.0及以下版本。
僅僅為了比較,下面是它如何尋找支持OpenGL-4.x的OpenGL實現(NVidia),甚至在核心配置文件之外:
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 tops。
為了使用核心配置文件功能,請確保啟用它以及使用正確的預處理器指令編譯着色器
// Example using glut for context initialization
glutInitContextVersion(4, 5);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutInit(&argc, argv);
// Shaders
#version 450
...
在着色器中嘗試下一個代碼:
“#version 320 es
精密介質浮子;
......你的代碼“
GLSL是OpenGL使用的着色器語言,盡管兩個版本號並不總是匹配。 從您的輸出,看起來您正在使用片上Intel GPU。 這個芯片的驅動程序是通過Mesa進行的,據我所知,它還不支持OpenGL 4。
如果您有Nvidia卡,則可以安裝支持最新OpenGL版本的專有NVidia驅動程序。 否則,您需要修改着色器以使用該語言的舊版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.