View Full Version : Need help to supply colors as unsigned char...

02-19-2007, 06:09 AM

I have data that have colors as unsigned char for
RGBA (from 0 to 255).

I would like to know if there is a way to supply those to glColorPointer()...

For now, unless I change the data format, the only way I can supply a color is:

glColor4f((currColor.red * ONEOVER255), (currColor.green * ONEOVER255), (currColor.blue * ONEOVER255), (currColor.alpha * ONEOVER255));No need to say that all of these conversions to float variables are not really effficient...

And unless I create a new array at run-time, with
these conversions, I cannot use glColorPointer...

Can someone help me ?

02-19-2007, 06:13 AM
where is the problem? you can set the second parameter, which defines the data type, to GL_UNSIGNED_BYTE.

02-19-2007, 06:31 AM
Ok... I'll try it...

02-19-2007, 06:47 AM
It works... Thanx. I did't tought it was so simple.

Is there a way to supply them with glColor, instead of using glColor4f ? I still some have
helper objects rendering functions that still render primitives with glBegin and glEnd, and I want to remove the conversion thing...

02-19-2007, 09:22 AM
Just use glColor4ub.