【发布时间】:2015-05-03 21:43:51
【问题描述】:
我正在尝试运行使用 LWJGL 和 GLSL 3.3 构建的 OpenGL 软件,但在 Linux Mint 17.1 和 Intel Ivy Bridge (HD4000) + Mesa 10.6.0-devel 下运行时遇到问题。
根据我的阅读,Mesa 10.1+ 应该支持 OpenGL 和 GLSL 3.3,用于 Sandry Bridge 和更新的 Intel CPU。
glxinfo | grep OpenGL 返回:
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile x86/MMX/SSE2
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.6.0-devel (git-4348046 2015-05-02 trusty-oibaf-ppa)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.6.0-devel (git-4348046 2015-05-02 trusty-oibaf-ppa)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 10.6.0-devel (git-4348046 2015-05-02 trusty-oibaf-ppa)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
(我猜我需要 OpenGL 着色语言版本字符串:3.30,而不仅仅是 Core Profile 3.3?)
在没有参数的情况下调用 Display.create() (LWJGL) 时出现以下错误:
> 0:1(10): error: GLSL 3.30 is not supported. Supported versions are:
> 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
和 glGetString(GL_VERSION) 返回:
> 3.0 Mesa 10.6.0-devel (git-4348046 2015-05-02 trusty-oibaf-ppa)
如果我尝试调用 Display.create() 并且核心配置文件为 true,如下所示:
Display.create(new PixelFormat(), new ContextAttribs(3,3).withProfileCore(true));
我收到以下错误:
0:11(6): error: operands of `==' must have the same type
而 GL_VERSION 是:
3.3 (Core Profile) Mesa 10.6.0-devel (git-4348046 2015-05-02 trusty-oibaf-ppa)
我不确定这意味着什么,或者我应该怎么做才能在英特尔集成显卡上运行 OpenGL 3.3。我很肯定同样的代码适用于 nVidia(4.4+ 支持)。
对此事的任何帮助将不胜感激,谢谢!
编辑:导致问题的着色器:
#version 330
in vec2 texCoord0;
uniform vec3 color;
uniform sampler2D sampler;
void main() {
vec4 textureColor = texture2D(sampler, texCoord0.xy);
if (textureColor == 0)
gl_FragColor = vec4(color, 1);
else
gl_FragColor = textureColor * vec4(color, 1);
}
比较 textureColor == vec4(0, 0, 0, 0) 确实有效,抱歉。
我现在可以运行它了。但我没有看到任何纹理。我会尝试找出问题所在,是否有任何明显的原因可能导致我的着色器出现这种情况?
【问题讨论】:
-
Mesa 仅在核心配置文件中支持 GL > 3.0。实际上,您在以后的尝试中设法获得了核心配置文件,并且 GLSL 编译器现在接受
#version 330指令。但是,您的着色器在第 11 行有一些语法错误,正如0:11(6): error: operands of '==' must have the same type试图告诉您的那样。您应该发布着色器源代码。着色器在 Nvidia 上工作的事实并不能真正证明什么。尤其是 nvidia 编译器非常草率,并且允许许多超出 GLSL 规范的结构。 -
谢谢,我会将着色器添加到原始问题中。我认为它们没有问题,因为我可以在另一台机器上运行这段代码。
标签: java opengl ubuntu 3d lwjgl