[GRASS-dev] Help with gsd_color_func() for NVIZ
Glynn Clements
glynn at gclements.plus.com
Thu Dec 7 02:54:22 EST 2006
Hamish wrote:
> I am trying to understand the OpenGL color setting code in NVIZ for changing
> the North Arrow text color. I am not very good with the bitwise/GL stuff,
> so can anyone give me a hand at understanding how to feed gsd_color_func()
> correctly?
>
>
> this is in lib/ogsf/gsd_objs.c and lib/ogsf/gsd_prim.c
>
> I was expecting 0x00000 to mean 0xRRGGBB, but it's backwards for me.
> The least significant pair comes first.
> (I'm running Pentium4 / 32bit / little endian)
That's how gsd_prim.c defines it:
> #define RED_MASK 0x000000FF
> #define GRN_MASK 0x0000FF00
> #define BLU_MASK 0x00FF0000
> #define ALP_MASK 0xFF000000
> some experiments:
>
> gsd_color_func(0xFF0000); r=0 g=0 b=-1 a=0
[snip]
> (am I doing %d with something that should be e.g. %c, %x?)
No; the variables:
> GLbyte r, g, b, a;
should be GLubyte; GLbyte is signed, i.e. 0xFF == -1.
This won't matter to the glColor4ub() call, which will cast them to
GLubyte, but it will matter to the fprintf() call, which will cast
them to int.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list