How to define constant array in GLSL (OpenGL ES 2.0)?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 08:49:14
Stefan Hanke

From the OpenGL ES SL 1.0 spec, paragraph 4.1.9 Arrays (p. 24):

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

Note that this has been intentionally left out. According to this post, the OpenGL ES SL version for OpenGL ES 2 is based on OpenGL SL 1.2. The same paragraph (p. 20) contains:

Arrays can have initializers formed from array constructors:

      float a[5] = float[5](3.4, 4.2, 5.0, 5.2, 1.1);
      float a[5] = float[](3.4, 4.2, 5.0, 5.2, 1.1);  // same thing
ivivaldi
precision highp float;

const float a[5] = float[5](3.4, 4.2, 5.0, 5.2, 1.1);

It's working with Android KitKat version (OpenGL ES 2.0).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!