【发布时间】:2014-03-31 23:52:11
【问题描述】:
我在尝试编译顶点着色器时遇到分段错误。我想我在传递顶点属性时发现了问题。以下行编译(它们可能不起作用,但它们仍然编译):
# version 330
layout(location=0) in vec4 in_Loc;
layout(location=1) in vec4 in_Color;
layout(location=2) in vec4 in_Norm;
还有
# version 330
layout(location=0) in vec4 in_Loc;
layout(location=1) in vec4 in_Color;
layout(location=25) in vec4 in_Norm;
但是
# version 330
layout(location=0) in vec4 in_Loc;
layout(location=1) in vec4 in_Color;
layout(location=2) in vec4 in_Norm;
layout(location=33) in vec4 in_Anything
不会编译。我想我只能定义 3 个 vec4 属性。但是,带有 GL_MAX_VERTEX_ATTRIBS 的 glGetIntegerv 返回 16,这符合 OpenGL 标准。这是与我的硬件相关的某种错误吗?我使用的是英特尔显卡
*-display
description: VGA compatible controller
product: 3rd Gen Core processor Graphics Controller
vendor: Intel Corporation
physical id: 2
bus info: pci@0000:00:02.0
version: 09
width: 64 bits
clock: 33MHz
capabilities: msi pm vga_controller bus_master cap_list rom
configuration: driver=i915 latency=0
resources: irq:49 memory:f0000000-f03fffff memory:e0000000-efffffff ioport:3000(size=64)
和台面 10:
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.1.0
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile.
操作系统是 ubuntu 14.04。
【问题讨论】:
-
如果您的 GL 只有 16 个属性,为什么还要指定这么大的位置索引?但无论如何它不应该崩溃,您可以在您的问题中添加 c crash backtrace 吗?
-
@keltar:在尝试查找错误源时,我尝试了“正常”位置,效果是一样的。我不确定如何获得 c 崩溃回溯,因为我在 glCompileShader 期间遇到了一个简单的分段错误。
-
在调试器(
gdb ./your_program)中运行,然后当报告崩溃时,输入bt命令。使用调试器总是好的。 -
@keltar:这需要我一点时间,因为我是从 python 调用函数(使用 cython)。但我无法想象这可能是错误的根源。
标签: opengl glsl vertex-attributes