OpenGL ES 2.0 - vec2的数组。

时间:2021-09-23 05:46:36

I have a GLSL shader program running my iPhone app (it's a very very simple shader). I am trying to declare an array of vec2 but I'm having a lot of trouble. My shader is wrapped in a thrid party library, so unfortunately I can't get any real information about the actual error in syntax is.

我有一个GLSL着色程序运行我的iPhone应用程序(它是一个非常简单的着色程序)。我试图声明一个vec2的数组,但是我遇到了很多麻烦。我的着色器被包装在一个thrid party库中,因此不幸的是,我不能得到任何关于语法错误的真实信息。

My code (not working) to declare an array of vec2 is:

我声明vec2数组的代码(不工作)是:

highp vec2 steps[5] = vec2[](
                            vec2(   0.0015625,  0.00208333333333),
                            vec2(    0.003125,  0.00416666666667),
                            vec2(     0.00625,  0.00833333333333),
                            vec2(      0.0125,  0.0166666666667),
                            vec2(       0.025,  0.0333333333333)
                            );

Does anyone have any idea how to create an array of vec2 datatypes in OpenGLES 2.0?

有人知道如何在OpenGLES 2.0中创建一个vec2数据类型数组吗?

2 个解决方案

#1


3  

highp vec2 steps[5] = {
                            vec2(   0.0015625,  0.00208333333333),
                            vec2(    0.003125,  0.00416666666667),
                            vec2(     0.00625,  0.00833333333333),
                            vec2(      0.0125,  0.0166666666667),
                            vec2(       0.025,  0.0333333333333)
                            };

#2


2  

I think it's possible to create, but I am not sure it's possible to initialize it at declaration time. According to the OpenGL ES specification, http://www.khronos.org/files/opengles_shading_language.pdf

我认为有可能创建,但我不确定是否有可能在声明时初始化它。根据OpenGL ES规范,http://www.khronos.org/files/opengles_shading_language.pdf

There is no mechanism for initializing arrays at declaration time from within a shader.

在声明时,没有从着色器内部初始化数组的机制。

#1


3  

highp vec2 steps[5] = {
                            vec2(   0.0015625,  0.00208333333333),
                            vec2(    0.003125,  0.00416666666667),
                            vec2(     0.00625,  0.00833333333333),
                            vec2(      0.0125,  0.0166666666667),
                            vec2(       0.025,  0.0333333333333)
                            };

#2


2  

I think it's possible to create, but I am not sure it's possible to initialize it at declaration time. According to the OpenGL ES specification, http://www.khronos.org/files/opengles_shading_language.pdf

我认为有可能创建,但我不确定是否有可能在声明时初始化它。根据OpenGL ES规范,http://www.khronos.org/files/opengles_shading_language.pdf

There is no mechanism for initializing arrays at declaration time from within a shader.

在声明时,没有从着色器内部初始化数组的机制。