glsl es const mat2 array

1.4k views Asked by At

I try to compile the following code in Open GL ES 2.0 (in RenderMonkey):

const mat2 ma[2] =  mat2[2](
                     mat2( vec2(0.0, -1.0), vec2(1.0, 0.0) ),
                     mat2( vec2(0.0, -1.0), vec2(1.0, 0.0) )
                    );

But compiler says:

OpenGL ES Preview Window: Compiling vertex shader API(OpenGL ES) /Effect Group 1/Effect1/Pass 0/Vertex Program/ ... failure
   COMPILE ERROR: API(OpenGL ES) /Effect Group 1/Effect1/Pass 0/Vertex Program/ (13): ERROR: 0:13: 'constructor' : if a matrix argument is given to a matrix constructor, it is an error to have any other arguments. 
   COMPILE ERROR: API(OpenGL ES) /Effect Group 1/Effect1/Pass 0/Vertex Program/ (10): ERROR: 0:10: '=' :  cannot assign to 'const array of 2X2 matrix of float'

What I am doing wrong?

1

There are 1 answers

2
jozxyqk On BEST ANSWER

[EDIT]

In webgl/chrome, I get this:

ERROR: 0:4: 'ma' : arrays may not be declared constant since they cannot be initialized 
ERROR: 0:4: '=' : syntax error 

It doesn't look good.

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


Desktop GL...

Your code works for me, however I get this without setting a version:

warning C7551: OpenGL first class arrays require #version 120

Can you provide a #version string in RenderMonkey?

I doubt this is the case but a really old card or drivers may be a factor.

I don't think you need the second 2 either: const mat2 ma[2] = mat2[](... is fine