PDA

View Full Version : Converting Hex to OpenGL Colors



JEEP THANG
11-06-2001, 12:52 PM
Does anybody know how to convert a hexadecimal color value to an opengl color value. I use VB, any help would be appreciated.

Oh Yeah! Thanks to everyone that gave a response to my previous post. They lead me to the info I needed.

Sincerely: JEEP THANG
Larry George
USAR

UrbanLedgend
11-06-2001, 01:34 PM
Hi

On MS windows based stuff you could do

COLORREF ColRef = 0xffffaa10; // your hex number etc

float m_ColorR = GetRValue( ColRef );
float m_ColorG = GetGValue( ColRef );
float m_ColorB = GetBValue( ColRef );

Then normalise for Opengl


m_ColorR = m_ColorR / 255.0f;
m_ColorG = m_ColorG / 255.0f;
m_ColorB = m_ColorB / 255.0f;

Gordon.

UrbanLedgend
11-06-2001, 03:51 PM
Whoops

COLORREF the hightest order byte has to be 00 so the max hex is 0x00FFFFFF