PDA

View Full Version : Converting RGBA values.



cashew86
12-05-2007, 02:23 PM
I am a little new to OpenGL programming so go easy on me :) I read an article containing advanced programming techniques, in which was covered changing RGBA color values into Hue, Saturation, and Luminosity. I read somewhere that it was only supported by Silicone Graphics... Is there some other way to do this, or maybe someone could just point me into the right direction. My whole intent was to gradually change the hue and saturation of a rotating object in one of my projects and I just found it was really hard to do with just incrementing and decrementing the values in glColor4f based on rotation of the object. I'd appreciate any help with this! :)

ZbuffeR
12-05-2007, 03:51 PM
First, that was "Silicon Graphics" ... we are not talking about breast implants here :)
Then, please name your sources. "I read an article" or "I read somewhere" do not count.
Last, just search the web for "rgb to hsl" and implement this :
http://en.wikipedia.org/wiki/HSL_color_space#Conversion_from_RGB_to_HSL_or_HSV

- convert original rgb color to hsl
- tweak hsl values
- convert new hsl back to rgb
- glColor()

You should have enough info now, good luck.

I tried a lot to be gentle :D

cashew86
12-05-2007, 05:55 PM
Could have been worse(So I appreciate your leniency), and yes - that was a bad mistype on my part. I have not really done much with manipulating color other than RGBA values so I was unaware of that acronym HSL or HSV. I found this website after posting my question:

http://www.cs.bham.ac.uk/~mer/colour/hsv.html

which explained alot with a sample algorithm C++ for converting back and forth from HSV/HSL and RGB

You also were right about not referencing what "I read...". Though I was speaking of this:

http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/notes.html

13.2.4 The Color Matrix Extension.

But thanks for replying and helping ZbuffeR ^_^.

ZbuffeR
12-06-2007, 06:02 AM
In fact this color matrix extension seem to be widely supported in ATI hardware, but not nvidia, according to this list :
http://delphi3d.net/hardware/extsupport.php?extension=GL_SGI_color_matrix

Anyway, it does look a bit suspicious.
It looks better to do it by hand, either on the CPU and glColor, or with a fragment shader sampling from a texture for more advanced and realtime stuff.