0

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?

tower120
  • 5,007
  • 6
  • 40
  • 88

1 Answers1

0

[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

Community
  • 1
  • 1
jozxyqk
  • 16,424
  • 12
  • 91
  • 180
  • You should try to run it on GL ES device, like android, or webGL. And on the RenderMonkey make sure you use GL ES effect group. If so - you can use only #version 100. #version 120 - for desktop GL – tower120 Feb 20 '14 at 15:49
  • @tower120 My bad, I completely missed the GL ES part. I'm not sure it's possible, but don't know for sure. Just tried in webgl. – jozxyqk Feb 20 '14 at 16:16