4

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.

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

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?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Brett
  • 11,637
  • 34
  • 127
  • 213

2 Answers2

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

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

endavid
  • 1,781
  • 17
  • 42
-4
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)
                            };
giorashc
  • 13,691
  • 3
  • 35
  • 71