Hi, I wrote me a little glsl macro to initialize color constants with a hex number like 0xFF0000 for red.
so the macro looks like:
#define HexColor(x) (vec3((x>>16)&0xFF,(x>>8)&0xFF,(x)&0xFF)/255)
I run it succesfully on an Intel onboard card, but when I trie to use it with my 5770 I got these strange compile errors:
ERROR: 0:100: error(#143) Undeclared identifier undefined
ERROR: 0:100: error(#132) Syntax error: '<' parse error
when I split the macro into several lines like this:
(x>>8 ) &0xFF,\\
) / 255\\
the first error disapears.
Now the strange thing, when I use the code directly without the define, so:
const vec3 COLOR = (vec3((0xFFB86B>>16)&0xFF,(0xFFB86B>>8)&0xFF,(0xFFB86B)&0xFF) /255) ;
const vec3 COLOR = HexColor(0x6B9FFF);
everything works fine.
I can of course create a function which works just fine, but I can't use it then for constants.
I wouldn't complain if the code wouldn't work at all, but it just don't work if used through a macro
That is strange indeed. We will look into it. In the meantime, you can use GLSL's built in function for this:
vec4 unpackUnorm4x8(uint p);
If you want to replace your macro (which I notice returns a vec3), you can do:
#define HexColor(x) unpackUnorm4x8(x).gba