无法在WebGL 1.0中声明数组

发布于 2025-02-12 11:13:20 字数 356 浏览 2 评论 0原文

我正在尝试将着色器从GLSL 300 ES移植到GLSL 100,因此它可以在更多的设备上使用。我有一个数组,它在GLSL 300 ES上效果很好,但是在GLSL 100上,它不起作用。 为了测试我的其他着色器的其他问题,还是阵列的问题,我在最小的着色器中添加了一个简单的数组。

#version 100
attribute vec2 Pos;

void main()
{
    float[2] test;
    gl_Position = vec4(Pos,0,0);
}

当此着色器被编译时,WebGL给了我这个错误:

错误:0:6:'一流阵列':不支持

I'm trying to port a shader from glsl 300 es to glsl 100, so it works on more devices. I have an array, it works completly fine on glsl 300 es, but on glsl 100 it just does not work.
To test if it's an issue with the rest of my shader, or an issue with the array I added a simple array to the most minimal shader.

#version 100
attribute vec2 Pos;

void main()
{
    float[2] test;
    gl_Position = vec4(Pos,0,0);
}

When this shader is compiled webgl gives me this error:

ERROR: 0:6: 'first-class array' : not supported

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

メ斷腸人バ 2025-02-19 11:13:20

正确的语法为

float [2] test;

float test[2];

另请参见数据类型(GLSL) - 数组

The correct syntax is

float[2] test;

float test[2];

See also Data Type (GLSL) - Array

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文