Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OpenGL / GLSL / const arrays ? Cannot get a simple lookup table to work...

396 views
Skip to first unread message

Samuel Williams

unread,
May 2, 2008, 6:39:44 AM5/2/08
to
Hello,

I have a shader which I want to have a small (8x vec2) lookup table.
For simplification, I'll use two elements.. (2x vec2)

const vec2 L[2] = vec2[](vec2(0.0, 1.0), vec2(0.0, 2.0));

This doesn't compile:

ERROR: 0:19: 'array of 2-component vector of float' : constructor not
supported for type
ERROR: 0:19: 'array of 2-component vector of float' : no matching
overloaded function found
ERROR: 0:19: 'const 2-component vector of float' : cannot declare
arrays of this type
ERROR: 0:19: 'L' : redefinition

So.. I tried this next:

const float L[4] = float[] (0.0, 1.0, 0.0, 2.0);

This doesnt' compile either:

ERROR: 0:19: 'array of float' : constructor not supported for type
ERROR: 0:19: 'array of float' : no matching overloaded function found
ERROR: 0:19: 'const float' : cannot declare arrays of this type
ERROR: 0:19: 'L' : redefinition

I copied a declaration from what appears to be the GLSL reference
documentation (section 5.4.4 of http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf).

const float c[3] = float[3](5.0, 7.2, 1.1);
const float d[3] = float[](5.0, 7.2, 1.1);

Neither of these compiled either:

ERROR: 0:19: 'array of float' : constructor not supported for type
ERROR: 0:19: 'array of float' : no matching overloaded function found
ERROR: 0:19: 'const float' : cannot declare arrays of this type
ERROR: 0:19: 'c' : redefinition
ERROR: 0:20: 'array of float' : constructor not supported for type
ERROR: 0:20: 'array of float' : no matching overloaded function found
ERROR: 0:20: 'const float' : cannot declare arrays of this type
ERROR: 0:20: 'd' : redefinition

What is going on here?

The shader is running at #version 120.

Is someone else able to test and confirm this behaviour?

NVIDIA GeForce 8600M GT OpenGL Engine 2.0 NVIDIA-1.5.26
Running on Mac OS X 10.5.2

Should I be using a texture lookup for this instead? It seems a bit
stupid for such a small amount of data...

Regards,
Samuel

Samuel Williams

unread,
May 12, 2008, 8:07:59 AM5/12/08
to
I thought I'd mention that I submitted a detailed report of this
behaviour (or lack of) to Apple's bug reporting system, and they
replied soon indicating my report was actually a duplicate, and that
they were looking into it.

So.... the spec is correct, but it isn't implemented as far as I can
tell.

If anyone else is able to test and let me know, please do.

Regards,
Samuel

0 new messages